1"use strict";(self.webpackChunkyoda=self.webpackChunkyoda||[]).push([[2761],{70852:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>d,contentTitle:()=>r,default:()=>p,frontMatter:()=>a,metadata:()=>s,toc:()=>l});var i=t(85893),o=t(11151);const a={slug:"developers-guide-to-getting-started-with-android-sdk",title:"Developer's Guide to Getting Started With the Android SDK",authors:"yash",description:"Learn step-by-step on installing and using Android SDK. Get answers on common SDK questions. Click to learn",img:"/img/blog/developers-guide-to-getting-started-with-android-sdk.png",tags:["AndroidSDK","Android Guide","Android Development","Emulators","Build Tool","Android Platform"],blogCategory:"Learning"},r=void 0,s={permalink:"/blog/developers-guide-to-getting-started-with-android-sdk",source:"@site/blog/2023-06-05-developers-guide-to-getting-started-with-android-sdk/index.mdx",title:"Developer's Guide to Getting Started With the Android SDK",description:"Learn step-by-step on installing and using Android SDK. Get answers on common SDK questions. Click to learn",date:"2023-06-05T00:00:00.000Z",formattedDate:"June 5, 2023",tags:[{label:"AndroidSDK",permalink:"/blog/tags/android-sdk"},{label:"Android Guide",permalink:"/blog/tags/android-guide"},{label:"Android Development",permalink:"/blog/tags/android-development"},{label:"Emulators",permalink:"/blog/tags/emulators"},{label:"Build Tool",permalink:"/blog/tags/build-tool"},{label:"Android Platform",permalink:"/blog/tags/android-platform"}],readingTime:7.425,hasTruncateMarker:!1,authors:[{name:"Yash Khandelwal",title:"Maintainer of Dashwave Blog",url:"https://github.com/ykhandelwaly",imageURL:"https://github.com/ykhandelwaly.png",key:"yash"}],frontMatter:{slug:"developers-guide-to-getting-started-with-android-sdk",title:"Developer's Guide to Getting Started With the Android SDK",authors:"yash",description:"Learn step-by-step on installing and using Android SDK. Get answers on common SDK questions. Click to learn",img:"/img/blog/developers-guide-to-getting-started-with-android-sdk.png",tags:["AndroidSDK","Android Guide","Android Development","Emulators","Build Tool","Android Platform"],blogCategory:"Learning"},unlisted:!1,prevItem:{title:"Implementing edit text in a RecyclerView",permalink:"/blog/implementing-edit-text-in-recyclerview"},nextItem:{title:"Android Studio Plugins to Boost Productivity",permalink:"/blog/android-studio-plugins-to-boost-productivity"},threeRelatedPosts:[{id:"android-studio-plugins-to-boost-productivity",metadata:{permalink:"/blog/android-studio-plugins-to-boost-productivity",source:"@site/blog/2023-05-30-android-studio-plugins-to-boost-productivity/index.mdx",title:"Android Studio Plugins to Boost Productivity",description:"Here are the top Android Studio plugins to boost your app development productivity. Check the list.",date:"2023-05-30T00:00:00.000Z",formattedDate:"May 30, 2023",tags:[{label:"Android Studio Plugins",permalink:"/blog/tags/android-studio-plugins"},{label:"Developer Productivity",permalink:"/blog/tags/developer-productivity"},{label:"Optimize Speed",permalink:"/blog/tags/optimize-speed"},{label:"Android Development",permalink:"/blog/tags/android-development"},{label:"Plugins",permalink:"/blog/tags/plugins"},{label:"Developer Efficiency",permalink:"/blog/tags/developer-efficiency"}],readingTime:8.145,hasTruncateMarker:!1,authors:[{name:"Yash Khandelwal",title:"Maintainer of Dashwave Blog",url:"https://github.com/ykhandelwaly",imageURL:"https://github.com/ykhandelwaly.png",key:"yash"}],frontMatter:{slug:"android-studio-plugins-to-boost-productivity",title:"Android Studio Plugins to Boost Productivity",authors:"yash",description:"Here are the top Android Studio plugins to boost your app development productivity. Check the list.",img:"/img/blog/android-studio-plugins-to-boost-productivity.png",tags:["Android Studio Plugins","Developer Productivity","Optimize Speed","Android Development","Plugins","Developer Efficiency"],blogCategory:"Learning"},unlisted:!1,prevItem:{title:"Developer's Guide to Getting Started With the Android SDK",permalink:"/blog/developers-guide-to-getting-started-with-android-sdk"},nextItem:{title:"Make your own Permission Checker app in Android Studio",permalink:"/blog/permission-checker-app-in-android-studio"}},content:'import PluginCard from "@site/src/components/common/PluginCard";\nimport Divider from "@site/src/components/common/Divider";\n\nAndroid Studio is one of the bests applications for making an Android app.\n\nThe Android Studio version is constantly updated to offer several essential features for Android developers to create apps efficie
1ntly and fast.\n\nBefore we dive into Android Studio plugins - one of the most essential solutions for developers to build great apps fast, let\u2019s do a recap of the basics of Android Studio.\n\nIn case you missed it, the latest Android\xa0 Studio version was Hedgehog | 2023.1.1. This comes with the required latest Android Studio plugin version\xa0 ( 3.2-8.2) for you to develop and deploy apps efficiently.\n\nHowever, since the list of Android Studio plugins is numerous, we have put together the best plugins that would help you fast-track your app development period. And more important, deploy Android apps that meet the audience\u2019s needs in features and user experience.\n\nIn the list are two underdog Android plugins you should take advantage of to speed up your app development productivity.\n\n## **Top Android Studio Plugins**\n\n###\n\n### 1.**ADB Idea**\n\nADB Is a command line that lets you communicate with an Android device that is connected to an emulator or a USB.\xa0 This enables you to pull data such as memory usage data and push & pull applications from the device.\n\nAn [ADB Idea](https://plugins.jetbrains.com/plugin/7380-adb-idea) is an Android Studio plugin that enables several shortcuts to ADB tool commands from your Integrated Development Environment (IDE) directly. Furthermore, it also works in the IntelliJ IDEA ecosystem.\n\nSince the ADB Idea is off by default, you can enable it by doing the following; If you are using a USB, enable debugging in the device system settings, under Developer options.\n\n[ADB WiFi](https://plugins.jetbrains.com/plugin/7856-adb-wifi) is another related ADB Android studio plugin you can enable debugging Android apps over the internet connection. Here are the steps to using ADB WiFi:\n\n**Step 1:** Connect the Android device and ADB host computer to a common Wi-Fi network accessible to both. It\u2019s important to note that not all access points are suitable; you may need to use an access point whose firewall is configured properly to support ADB.\n\n**Step 2:** Connect the device with a USB cable to the host.\n\n**Step 3:** Make sure ADB is running in USB mode on the host.\n\n**Step 4:** In\xa0 Android Studio: go to tool \u2192 android \u2192 ADB WIFI \u2192 ADB USB to WIFI.\n\n<Divider></Divider>\n<br />\n<PluginCard></PluginCard>\n<br />\n<Divider></Divider>\n\n### 2. **Scala**\n\n[Scala\u2019s Sbt-Android](https://plugins.jetbrains.com/plugin/1347-scala) plugin enables you to easily build and run Android applications from Sbt Console using Sbt tasks.\n\nThe plugin also supports joint compilations. This allows you to freely mix Java and Scala code with dependencies in both directions.\n\nThe [Scala plugin](https://docs.gradle.org/current/userguide/scala_plugin.html) adds the following extensions which you can use in your build script as though they were properties of the source set object.\n\n**scala - SourceDirectorySet** which contains .scala and .java files found in the Scala source directories, and excludes all other types of files.\n\n**scala. srcDirs -** The source directories contain Scala source files but may also contain Java source files for joint compilation. The default value is [*projectDir*/src/*name*/scala].\n\nAllscala -\xa0 **FileTree** contains all the Scala source files of this source set and contains only the .scala source files.\n\n\n\n### 3. **Name That Color**\n\nWe all occasionally name a color or two correctly. However, when writing code for mobile or web applications, its time consuming to switch tabs for color reference.\n\nUsing the [Name that Color plugin](https://plugins.jetbrains.com/plugin/10422-name-that-color) you can easily name the color you have in our clipboard directly inside your color resource file in Android Studio.\n\nYou no longer have to use \u2018lighter_light_pink\u2019 in your XML file with the Name that colors plugin.\n\n### 4. **String Manipulation**\n\nA string is an array of character data types. String manipulation is where a user is asked to process a given string and change its data.\n\nFor example, you can [manipulate str
1ings in Kotlin](https://www.javatpoint.com/kotlin-string) programming language without necessarily changing the length or elements since they are immutable anyway.\n\nUnlike Java and other programming languages, you can instantiate an object of a string class in Kotlin without requiring any new keywords. You can simply declare a String with a double quote ( \u201c \u201c ).\n\n`val str1 = "Hello, Dashwave"`\n\n`val str2 = """Welcome To Dashwave"""`\n\nThe [string manipulation plugin](https://plugins.jetbrains.com/plugin/2162-string-manipulation) pretty much filters, sorts, switches, and does more to string automatically saving you time and energy.\n\n### 5. **Shifter**\n\nThe shifter is one of those underdog Android Studio plugins. To those not using the plugin already, you may not know you need it until you try it out. It saves you from performing repetitive coding tasks.\n\nThe [shifter android plugin](https://plugins.jetbrains.com/plugin/6149-shifter) enables you to take string manipulation to the next level. You can easily execute code and string manipulation using various keyboard shortcuts.\n\nThere are a couple of Shifter types to take note of:\n\n- When sorting, you can shift a selected (from question mark on) ternary expression, and swap "then" and "else" statements.\n- For number shifting like numeric block selection, you open a dialog to choose: and you can execute either an in/decrement each or replace by enumeration.\n\nTo get started use the following commands:\n\n- Ctrl+Shift+Alt+Comma - Shift down word at caret / inline / sort selected lines ascending\n- Ctrl+Shift+Alt+Period - Shift up word at caret / inline/sort selected lines descending\n- Ctrl+Shift+Alt+J - Shift-Down More\n- Ctrl+Shift+Alt+K - Shift-Up More\n\n### 6. **Rainbow Brackets**\n\nIdentifying code blocks can be tricky for the naked eye. It\'s even worse when all brackets are in the same color. However, using the [Rainbow Brackets plugin](https://plugins.jetbrains.com/plugin/10080-rainbow-brackets) on Android app development, you can easily identify code along a block.\n\nOne of the standout features of Rainbow Brackets is its ability to handle multiple programming languages. Whether you are working on a project in Python, Java, or JavaScript, Rainbow Brackets ensures that your code is properly formatted and easy to read.\n\n\n\n### 7. **JSON Formatter**\n\nInstead of constantly switching tabs, especially when you want to format, the [JSON Formatter plugin](https://plugins.jetbrains.com/plugin/13931-json-formatter) helps you navigate formatting fast and easily without necessarily re-starting the IDE.\n\nSome of the [features in JSON Formatter\'s](https://chrome.google.com/webstore/detail/json-formatter/bcjindcccaagfpapjjmafapmmgkkhgoa) new release include;\n\n- Dark mode\n- Syntax highlighting\n- Fast and even longer JSON pages\n- Negligible performance impact on non-JSON pages (less than 1 millisecond)\n- Collapsible trees, with indent guides\n\nTo get started with JSON Formatter on your device, do the following;\n\n- Paste the JSON string into the editor,\n- Press **Reformat Code** (Ctrl + Alt + L in Windows) to format code as if you editing a file with a .json suffix.\n- The plugin panel will appear on the right side of the window after installation, and you don\'t have to restart the IDE.\n- Make sure that you have enabled the "Tool Window Bars" in Edit -> Appearance -> Tool Window Bars.\n\nFor those using Kotlin language for your Android app, consider installing [JSON To Kotlin Class plugin](https://plugins.jetbrains.com/plugin/9960-json-to-kotlin-class-jsontokotlinclass-) if you haven\u2019t. You can easily convert Json String into Kotlin data class code using this Android Studio plugin.\n\nSome of JSON TO Kotlin Class features include:\n\n- Formatting any legal JSON string\n- custom define data class, parent class\n- Generating Kotlin classs as individual classes\n- Customizing your own annotations\n\n### 8. **Code Iris**\n\nIn your journey to build a comprehensive Android application, you will c
1onstantly increase the number of modules, dependencies, and packages required.\n\nTo keep track of all these, you will need the [Code Iris plugin.](https://plugins.jetbrains.com/plugin/7324-code-iris) This Android Studio plugin acts as your \u2018 Google Maps\u2019 of your source code. It gives you the ability to filter, and highlight classes making it easy to navigate across your code.\n\nOther notable features of Code Iris include:\n\n- Manual layouting\n- Basic structure metrics\n- Experimental Kotlin analysis\n- Visualize classes and other dependencies\n\n\n\n### 9. **QAplug**\n\n[QAPlug in Android Studio](https://plugins.jetbrains.com/plugin/4594-qaplug) adds quality to code in the IntelliJ IDEA by integrating with tools like Findbugs, Checkstyle, and PMD.\n\nTo get started, do the following\n\n1. Select \u2018Analyze code\u2019 from the context menu\n2. Choose the appropriate scope and analysis profile\n3. Run analysis\n4. Browse and fix problems with your code\n\n### 10. **TabNine**\n\nThe rise of AI coding assistant tools continues. I could consider these tools underdogs for now, but soon developers will see the underlying value - ship apps faster. Example tools include: [Github Copilot](https://github.com/features/copilot) and [Tabnine](https://www.tabnine.com/)\n\n[TabNine plugin](https://plugins.jetbrains.com/plugin/12798-tabnine-ai-code-completion-js-java-python-ts-rust-go-php--more) makes you a better app developer. The AI code assistant is designed to increase your coding velocity by crowdsourcing real-time code from the most popular IDEs and coding languages.\n\n<figure\n style={{ width: "100%", height: "100%", margin: 0 }}\n class="video_container"\n>\n <video\n style={{ width: "100%", height: "100%" }}\n controls="true"\n loop="true"\n autoPlay\n muted\n >\n <source\n src="/img/blog/android-studio-plugins-to-boost-productivity-assets/main.mp4"\n type="video/mp4"\n />\n </video>\n</figure>\n\n### **11. Butterknife Zelezny**\n\nWhile most developers may know about JakeWharton\u2019s Butterknife annotation library, now there exists an Android plugin that allows you to inject views into Android components.\n\nThe [Butterknife Zelezny plugin](https://plugins.jetbrains.com/plugin/7369-android-butterknife-zelezny) allows you o save time, avoid repetitive coding, and deploy your Android app faster. Some of its features include:\n\n- Provide an event listener\n- Setting View property\n- Also Binding resources\n- Optimize code\n- Binding View\n- Provide List Adapter\n\n## **Use Android Studio Plugins**\n\nThe number of Android studio plugins on the JetBrains marketplace is robust. However, you have to choose those that meet your app development needs.\n\nSome of these plugins are already mentioned in the listicle above. The most relevant ones for any Android developer looking to develop and ship apps faster to say the least.\n\nTo sum up, if there is any Android Studio plugin mentioned above that is not among your developer toolkit, consider installing it today. Otherwise, keep learning, and keep developing great Android applications.'},{id:"understanding-swipe-drag-gestures-in-recyclerview",metadata:{permalink:"/blog/understanding-swipe-drag-gestures-in-recyclerview",source:"@site/blog/2023-05-16-understanding-swipe-drag-gestures-in-recyclerview/index.mdx",title:"Understanding swipe and drag gestures in RecyclerView",description:"Learn how to implement swipe and drag gestures in your android application in RecyclerView",date:"2023-05-16T00:00:00.000Z",formattedDate:"May 16, 2023",tags:[{label:"Android",permalink:"/blog/tags/android"},{label:"Android Development",permalink:"/blog/tags/android-development"},{label:"Gestures",permalink:"/blog/tags/gestures"},{label:"Kotlin",permalink:"/blog/tags/kotlin"},{label:"RecyclerView",permalink:"/blog/tags/recycler-view"},{label:"Java",permalink:"/blog/tags/java"}],readingTime:8.3,hasTruncateMarker:!1,authors:[{name:"Ishank Nijhawan",imageURL:"https://miro.medium.com/v2/resize:fill:176:176/2*hMQJOWSUkqadZXcAFGf38g.png",key:"ishank"}
1],frontMatter:{slug:"understanding-swipe-drag-gestures-in-recyclerview",title:"Understanding swipe and drag gestures in RecyclerView",authors:"ishank",description:"Learn how to implement swipe and drag gestures in your android application in RecyclerView",img:"/img/blog/Understanding-swipe-drag-gestures-in-recyclerview.png",tags:["Android","Android Development","Gestures","Kotlin","RecyclerView","Java"],blogCategory:"Learning"},unlisted:!1,prevItem:{title:"Android Push Notifications using FCM",permalink:"/blog/android-push-notifications-using-firebase-cloud-messaging"},nextItem:{title:"Optimize Gradle Build Speed in Android Studio",permalink:"/blog/optimize-gradle-build-speed-android-studio"}},content:"Have you ever been curious about how swipe gestures work in Android apps? Good news! You can create the same features without using any extra libraries or complicated code. In this guide, we'll not only show you how to create Gmail-style swipe gestures, but also how to add drag-and-drop actions just like in the image below.\n\n<p align=\"center\" width=\"100%\">\n <img\n src=\"/img/blog/Understanding-swipe-drag-gestures-assets/swipe-gesture-example1.gif\"\n alt=\"Swipe gesture example 1\"\n />\n</p>\n\nI won't go into detail on the basics, such as the item XML and [Adapter classes](https://www.javatpoint.com/java-adapter-classes). You can find the complete example in the source code provided at the end of this post. Instead, I'll focus on explaining the core concepts of swipe gestures and drag-and-drop action.\n\n## Swipe gestures\n\nLet's start with the essentials. We'll need the device's width and height, icon references, color, and a basic list. Additionally, we've created an [extension function](https://kotlinlang.org/docs/extensions.html) that we'll use frequently to convert pixel dimensions into dynamic pixels (dp) for better adaptability.\n\n```kotlin\nclass MainActivity : AppCompatActivity() {\n\n // Declare two variables: dragHelper and swipeHelper, both of type ItemTouchHelper\n private lateinit var dragHelper: ItemTouchHelper\n private lateinit var swipeHelper: ItemTouchHelper\n\n override fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n setContentView(R.layout.activity_main)\n\n // Get the device's width and height in dynamic pixels (dp)\n val displayMetrics: DisplayMetrics = resources.displayMetrics\n val height = (displayMetrics.heightPixels / displayMetrics.density).toInt().dp\n val width = (displayMetrics.widthPixels / displayMetrics.density).toInt().dp\n\n // Get the delete and archive icons from resources\n val deleteIcon = resources.getDrawable(R.drawable.ic_outline_delete_24, null)\n val archiveIcon = resources.getDrawable(R.drawable.ic_outline_archive_24, null)\n\n // Find the RecyclerView with the ID rv_list\n val rvList = findViewById<RecyclerView>(R.id.rv_list)\n\n // Set up the colors for delete and archive actions\n val deleteColor = resources.getColor(android.R.color.holo_red_light)\n val archiveColor = resources.getColor(android.R.color.holo_green_light)\n\n // Create a list of strings and initialize our custom ItemAdapter with the list\n val list = arrayListOf<String>().apply {\n for (i in 0..100) {\n add(\"Item $i\")\n }\n }\n val adapter = ItemAdapter(this, list)\n\n // Set the adapter for our RecyclerView\n rvList.adapter = adapter\n\n // Define swipe helper here\n }\n\n // Extension property for Integers to convert them into dp using the TypedValue class\n private val Int.dp\n get() = TypedValue.applyDimension(\n TypedValue.COMPLEX_UNIT_DIP,\n toFloat(), resources.displayMetrics\n ).roundToInt()\n}\n```\n\nWith the basics in place, let's move on to the exciting part. We've already declared our swipe helper earlier; now it's time to add some code to make it work.\n\n```kotlin\nswipeHelper = ItemTouchHelper(object : ItemTouchHelper.SimpleCallback(\n 0,\n ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT\n ) {\n //more code here\n })\n```\n\nIn the code, we initialize `ItemTouchHelper` with an object of the same class. It requires two parameters: `dragDirs` and `swipeDirs`. We set `dragDirs` to 0 to keep the swipe logic and drag logic separate. As for `swipeDirs`, we want the item to be swipeable from both
1sides, allowing us to provide different functionalities for different directions, depending on your use case.\n\nAt this point, the IDE will show an error and prompt you to override two methods: `onMove()` and `onSwiped()`.\n\nLet's listen to the IDE and override these two methods.\n\n```kotlin\noverride fun onMove(\n recyclerView: RecyclerView,\n viewHolder: RecyclerView.ViewHolder,\n target: RecyclerView.ViewHolder\n) = true\n\noverride fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {\n val pos = viewHolder.adapterPosition\n list.removeAt(pos)\n adapter.notifyItemRemoved(pos)\n\n Snackbar.make(\n findViewById(R.id.ll_main),\n if (direction == ItemTouchHelper.RIGHT) \"Deleted\" else \"Archived\",\n Snackbar.LENGTH_SHORT\n ).show()\n}\n```\n\nThe `onMove()` method isn't important for swipe logic, while `onSwiped()` is called after the user has completely swiped the item. Inside `onSwiped()`, you can make an API call, delete a data entry or room, or show an alert dialog. In this example, we're removing the item from the list and notifying the adapter. You can also check the direction in which the user swiped using the `direction` parameter, as demonstrated in the Snackbar function.\n\nDon't forget to attach the helper to the RecyclerView as shown below:\n\n```kotlin\nswipeHelper.attachToRecyclerView(rvList)\n```\n\nAt this point, your swipe will work as expected but there\u2019s something missing right? Ah, yes! Where\u2019s the background you might ask, yeah we\u2019re on it.\n\n\n\nLet's override the `onChildDraw()` method, which provides several parameters like\ncanvas, the amount of swipe done in the horizontal and vertical direction, the viewHolder\ninstance, etc. We'll use these parameters to draw icons and colors while swiping\nin both the left and right directions.\n\n```kotlin\n// Override the onChildDraw() method\noverride fun onChildDraw(\n canvas: Canvas,\n recyclerView: RecyclerView,\n viewHolder: RecyclerView.ViewHolder,\n dX: Float,\n dY: Float,\n actionState: Int,\n isCurrentlyActive: Boolean\n) {\n // 1. Set the background color based on the swipe direction\n when {\n abs(dX) < width / 3 -> canvas.drawColor(Color.GRAY)\n dX > width / 3 -> canvas.drawColor(deleteColor)\n else -> canvas.drawColor(archiveColor)\n }\n\n // 2. Set the bounds for the icons\n val textMargin = resources.getDimension(R.dimen.text_margin).roundToInt()\n deleteIcon.bounds = Rect(\n textMargin,\n viewHolder.itemView.top + textMargin + 8.dp,\n textMargin + deleteIcon.intrinsicWidth,\n viewHolder.itemView.top + deleteIcon.intrinsicHeight + textMargin + 8.dp\n )\n archiveIcon.bounds = Rect(\n width - textMargin - archiveIcon.intrinsicWidth,\n viewHolder.itemView.top + textMargin + 8.dp,\n width - textMargin,\n viewHolder.itemView.top + archiveIcon.intrinsicHeight + textMargin + 8.dp\n )\n\n // 3. Draw the appropriate icon based on the swipe direction\n if (dX > 0) deleteIcon.draw(canvas) else archiveIcon.draw(canvas)\n\n // Call the superclass implementation of onChildDraw()\n super.onChildDraw(\n canvas,\n recyclerView,\n viewHolder,\n dX,\n dY,\n actionState,\n isCurrentlyActive\n )\n}\n\n```\n\nThe code might seem a bit complex at first glance, so let's break it down step by step. In the first part, we're setting the canvas' background color based on how much the user has swiped. Here's a clearer explanation of how we change the color based on the `dX` value:\n\n1. When `dX < (deviceWidth / 3)` or `dX < (-deviceWidth / 3)`, we show a gray color. We can simplify this by checking if the absolute value of `dX` is less than `(deviceWidth / 3)`.\n2. If `dX > (deviceWidth / 3)`, we show a RED color (represented by the `deleteColor` variable).\n3. In all other cases (i.e., when the user swipes left and `dX` is less than `deviceWidth / 3`), we show a GREEN color (represented by the `archiveColor` variable).\n\nThis approach allows us to change the background color depending on how far the user has swiped and the direction of the swipe.\n\n\n\nThe result of this code will be something like this.\n\n<p align=\"center\" width=\"100%\">\n <img\n src=\"/img/blog/Understanding-swipe-drag-gestures-assets/swipe-gesture-example2.gif\"\n alt=\"Swipe gesture example 2\"\n />\n</p>\n\nGreat, we're halfway through implementing the icon backgrounds. Now, let's put the icons in their proper positions. For a left-to-right swipe, we'll display a Trash can icon, and for a right-to-left swipe, we'll display an Archive icon. In step 2 of the code snippet, we've set the bounds for both icons.\n\nThe `Rect(...)` object takes four parameters: left, top, right, and bottom. These are the four points we need to define to position the icon. The additional 16dp and 8dp in the vertical coordinates account for the layout padding and drag icon padding, which are 16dp and 8dp, respectively.\n\nKeep in mind that `Rect(...)` takes coordinates, not directional margins. To print the icons, we define the coordinates from all four directions.\n\nLastly, we check if `dX` is positive; if so, we draw the Trash can icon; otherwise, we draw the Archive icon. With these steps completed, you'll see the icons when swiping from either side of the view.\n\n## Drag and drop gestures\n\nImplementing drag and drop gestures is similar to swipe gestures. However, for drag and drop, we specify the `dragDirs` as `ItemTouchHelper.UP` and `ItemTouchHelper.DOWN`, and `swipeDirs` as 0. If you're using a grid layout instead of a linear one, you can specify `dragDirs` in all directions.\n\n```kotlin\ndragHelper = ItemTouchHelper(object : ItemTouchHelper.SimpleCallback(\n ItemTouchHelper.UP or ItemTouchHelper.DOWN, 0\n) {\n // onMove() is called when the user drags an item\n override fun onMove(\n recyclerView: RecyclerView,\
1n viewHolder: RecyclerView.ViewHolder,\n target: RecyclerView.ViewHolder\n ): Boolean {\n // Increase the elevation of the dragged item to visually distinguish it\n viewHolder.itemView.elevation = 16F\n\n // Get the adapter positions of the dragged item and the target item\n val from = viewHolder.adapterPosition\n val to = target.adapterPosition\n\n // Swap the items in the data source and notify the adapter\n Collections.swap(list, from, to)\n adapter.notifyItemMoved(from, to)\n return true\n }\n\n // onSelectedChanged() is called when the drag action state changes\n override fun onSelectedChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int) {\n super.onSelectedChanged(viewHolder, actionState)\n // Reset the elevation of the item after the drag action is completed\n viewHolder?.itemView?.elevation = 0F\n }\n\n // onSwiped() is not used in drag and drop logic, so we leave it empty\n override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) = Unit\n})\n\n```\n\nIn this implementation, we utilize the `onMove()` method and leave the `onSwiped()` method empty. As we drag the item over other items, we swap the dragged item's position with the target position and notify the adapter about the moved items.\n\nYou can also modify the dragged item's appearance for a more '3D' effect. In this example, we increase the item's elevation to 16 units while it's being moved, and then set it back to 0 units in the `onSelectedChanged()` callback.\n\nDon't forget to attach the `dragHelper` to the RecyclerView, just like we did with the `swipeHelper`. This ensures that the drag and drop functionality works as intended in your app.\n\n```kotlin\ndragHelper.attachToRecyclerView(rvList)\n```\n\nThis method requires the user to long-press the item to activate the drag functionality, which is suitable for most cases. However, if you want to implement a drag-handle that doesn't require a long press and is always ready for dragging, you can achieve this easily with the help of a built-in function:\n\n```kotlin\nfun startDragging(holder: RecyclerView.ViewHolder) {\n dragHelper.startDrag(holder)\n}\n```\n\nAnd now you have to call this function from your adapter\u2019s\xa0`onBindViewHolder()` method like so.\n\n```kotlin\noverride fun onBindViewHolder(holder: ItemViewHolder, position: Int) {\n holder.textView.text = list[position]\n\n holder.dragButton.setOnTouchListener { _, _ ->\n context.startDragging(holder)\n return@setOnTouchListener true\n }\n}\n```\n\n<aside>\n\u261d Make sure to pass context as\xa0`MainActivity.kt`\xa0in the Adapter so as to be able to call the function\n\n</aside>\n\n## Conclusion\n\nAnd that\u2019s it!\n\nWe've successfully learned how to incorporate swipe and drag-and-drop gestures into your Android app with ease, without depending on external libraries or overly complex code. We've guided you through the process of setting up the essential components, adding visual elements to swipe gestures, and implementing drag-and-drop functionality with a user-friendly drag handle.\n\nYou can refer to the [source code](https://github.com/ishanknijhawan/SwipeGestures)\n\nHappy Coding! \u2728"},{id:"permission-checker-app-in-android-studio",metadata:{permalink:"/blog/permission-checker-app-in-android-studio",source:"@site/blog/2023-05-25-make-your-own-permission-checker-app-in-android-studio/index.mdx",title:"Make your own Permission Checker app in Android Studio",description:"Learn how to create a basic permission checker app in Kotlin and Android Studio that lists all apps according to their granted permissions",date:"2023-05-25T00:00:00.000Z",formattedDate:"May 25, 2023",tags:[{label:"Android Development",permalink:"/blog/tags/android-development"},{label:"Android Studio",permalink:"/blog/tags/android-studio"},{label:"App Development",permalink:"/blog/tags/app-development"},{label:"Kotlin",permalink:"/blog/tags/kotlin"}],readingTime:6.965,hasTruncateMarker:!1,authors:[{name:"Ishank Nijhawan",imageURL:"https://miro.medium.com/v2/resize:fill:176:176/2*hMQJOWSUkqadZXcAFGf38g.png",key:"ishank"}
1],frontMatter:{slug:"permission-checker-app-in-android-studio",title:"Make your own Permission Checker app in Android Studio",authors:"ishank",description:"Learn how to create a basic permission checker app in Kotlin and Android Studio that lists all apps according to their granted permissions",img:"/img/blog/permission-checker-app-in-android-studio.png",tags:["Android Development","Android Studio","App Development","Kotlin"],blogCategory:"Learning"},unlisted:!1,prevItem:{title:"Android Studio Plugins to Boost Productivity",permalink:"/blog/android-studio-plugins-to-boost-productivity"},nextItem:{title:"Android Push Notifications using FCM",permalink:"/blog/android-push-notifications-using-firebase-cloud-messaging"}},content:'Have you ever wondered which apps have been granted access to your device\'s camera or location? Or do you want to see a list of all the apps that have a specific permission? Unfortunately, Android doesn\'t have a built-in feature to easily display this information. However, in this article, we will show you how to create a basic application using Android Studio and Kotlin that will list all the apps according to the permissions they have been granted.\n\nTo get started, open up a new Android Studio project and create a layout file in your **activity_main.xml** file. If you don\'t feel like designing your own layout, feel free to copy the code we provide because we\'re not here to teach you how to design layouts! \ud83d\ude04\n\n```kotlin\n<?xml version="1.0" encoding="utf-8"?>\n<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\n xmlns:app="http://schemas.android.com/apk/res-auto"\n android:layout_width="match_parent"\n android:layout_height="match_parent"\n android:orientation="vertical">\n\n <Spinner\n android:layout_width="match_parent"\n android:id="@+id/spinner"\n android:padding="4dp"\n style="@style/Widget.AppCompat.DropDownItem.Spinner"\n android:layout_margin="8sp"\n android:layout_marginBottom="8sp"\n android:layout_height="?attr/actionBarSize"/>\n\n <TextView\n android:layout_width="match_parent"\n android:id="@+id/tvCount"\n android:layout_margin="8sp"\n android:textSize="20sp"\n android:layout_height="wrap_content"/>\n\n <androidx.recyclerview.widget.RecyclerView\n android:id="@+id/rv_main_list"\n android:layout_margin="4dp"\n android:layout_width="match_parent"\n android:layout_height="match_parent"/>\n\n</LinearLayout>\n```\n\nBefore we move on to our main activity, let\'s create an **item_layout.xml** file which will inform the recyclerview about the type of layout we want to display in our list. We\'ll keep it simple by designing a basic layout that will include the name of the app along with its corresponding icon.\n\n```kotlin\n<?xml version="1.0" encoding="utf-8"?>\n<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"\n android:layout_width="match_parent"\n android:layout_height="wrap_content"\n android:padding="8sp"\n xmlns:tools="http://schemas.android.com/tools"\n android:orientation="vertical">\n\n <ImageView\n android:layout_width="50dp"\n android:id="@+id/iv_icon"\n android:src="@mipmap/ic_launcher_round"\n android:layout_height="50dp"/>\n\n <TextView\n android:layout_width="wrap_content"\n tools:text="app name"\n android:id="@+id/tv_appname"\n android:layout_toEndOf="@id/iv_icon"\n android:textSize="20sp"\n android:layout_centerVertical="true"\n android:layout_marginStart="20dp"\n android:layout_height="wrap_content"/>\n\n</RelativeLayout>\n```\n\n## Implementation\n\nNow, let\'s get to the interesting part! Before we move on to our main activity, we need to create a data class for our app. This will allow us to pass both the app name and icon to be bound in our Adapter class. In case you\'re not familiar with data classes, they are essentially classes that come with all the getters and setters already built-in. If you\'re interested in learning more about data classes, check out this [informative article](https://www.callicoder.com/kotlin-data-classes/).\n\n```kotlin\ndata class AppName(val packageName: String, val appName: String, val appIcon: Drawable)\n```\n\nNow that we have everything set up, we\'re ready to rock in our main activity! To start with, we\'ll declare a few variables that will be initialized later on. Add the following code just above the `onCreate()` method in **MainActivity.kt** file:\n\n```kotlin\nlateinit var permissionsArray: ArrayList<String>\nlateinit var appPackageName: String\nlateinit var appName: String\nlateinit var appInfo: ApplicationInfo\nlateinit var appIcon: Drawable\nlateinit var adapter: AppAdapter\nlateinit var packages: MutableList<PackageInfo>\nprivate val appList = mutableListOf<AppName>()\nprivate val cameraList = mutableListOf<AppName>()\nprivate val contactsList = mutableListOf<AppName>()\nprivate val locationList = mutableListOf<AppName>()\nprivate val microphoneList = mutableListOf<AppName>()\nprivate val storagemediaList = mutableListOf<AppName>()\nprivate val smsList = mutableListOf<AppName>()\n```\n\nIn our code, we have several lists for various kinds of permissions, such as Camera, Location, Contacts, and so on. Moving on to the `onCreate()` method, we\'ll initialize the spinner with the `permissionsArray` and a spinner adapter using the following code:\n\n```kotlin\npermissionsArray = arrayListOf(\n "All apps",\n "Camera",\n "Contacts",\n "Location",\n "Microphone",\n "Storage & Media",\n "SMS"\n //or any other permission you want to check for\n )\n\nval arrayAdapter = ArrayAdapter(\n this,\n android.R.layout.simple_spinner_dropdown_item,\n permissionsArray\n )\n\n spinner.adapter = arrayAdapter\n```\n\nNext up, we\'ll initialize our **packages** list with all the installed app packages on our device like this:\n\n```kotlin\npackages = packageManager.getInstalledPackages(PackageManager.GET_META_DATA)\n```\n\nThe above code will return a list of all installed packages on our app. However, we also want to filter this list based on the chosen permission. But don\'t worry, we\'ll come to that in just a bit! For now, we\'ll run a for loop that will assign the **packages** list to our `appList` along with other parameters that we\'ll derive from our app package name, such as the app name itself and the app icon drawable.\n\n```kotlin\nfor (i in 0 until packages.size) {\n appPackageName = packages[i].packageName\n appInfo = packageManager.getApplicationInfo(appPackageName, 0)\n appName = packageManager.getApplicationLabel(appInfo) as String\n appIcon = packageManager.getApplicationIcon(appPackageName)\n\n if (packageManager.getLaunchIntentForPackage(appPackageName) != null) {\n appList.add(AppName(appPackageName, appName, appIcon))\n\n }\n}\n```\n\nIn the above code, we\'re iterating through the **packages** list and for each iteration, we\'re defining the appName and appIcon for the corresponding `appPackageName`. It\'s worth noting that we\'re not adding these parameters directly to our AppName class. This is because the packages list also includes many other package names that are pre-installed by Android on the device and we can\'t access them. So, we\'re checking to see if the app launch returns null before adding it to our appList (or any other list).\n\nNow, inside this if statement where we\'ve populated our `appList`, we\'ll also populate our other lists with an additional filter to check for a specific permission before adding. Let\'s create a function called `checkCameraPermission()` inside our MainActivity.kt file that takes appPackageName as a parameter and returns a boolean value.\n\n```kotlin\nprivate fun checkCameraPermission(appPackageName: String?): Boolean {\n return PackageManager.PERMISSION_GRANTED == packageManager.checkPermission(\n android.Manifest.permission.CAMERA,\n appPackageName\n )\n}\n```\n\nSometimes, we need to check for multiple permissions in certain functions. For instance, an app might request either **ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION** to perform location-related activities. Therefore, we need to check for both cases like this:\n\n```kotlin\nprivate fun checkLocationPermission(appPackageName: String?): Boolean {\n return (PackageManager.PERMISSION_GRANTED == packageManager.checkPermission(\n android.Manifest.permission.ACCESS_FINE_LOCATION,\n appPackageName\n )) or (PackageManager.PERMISSION_GRANTED == packageManager.checkPermission(\n android.Manifest.permission.ACCESS_COARSE_LOCATION,\n appPackageName\n ))\n}\n```\n\nYou can create other functions in a similar fashion and call them inside your if statement just like this.\n\n```kotlin\nif (packageManager.getLaunchIntentForPackage(appPackageName) != null) {\n appList.add(AppName(appPackageName, appName, appIcon))\n\n if (checkCameraPermission(appPackageName)) {\
1n cameraList.add(AppName(appPackageName, appName, appIcon))\n }\n if (checkContactsPermission(appPackageName)) {\n contactsList.add(AppName(appPackageName, appName, appIcon))\n }\n if (checkLocationPermission(appPackageName)) {\n locationList.add(AppName(appPackageName, appName, appIcon))\n }\n //similarly check for other permissions...\n```\n\nNow that we have all the lists, we just need to pass them to the recyclerview on the spinner item click. If you want to see your apps in alphabetical order, you can do so using the `sortBy()` function. We use the "it" keyword when sorting a list of objects to tell the list which parameter to use for sorting.\n\n```kotlin\nappList.sortBy { it.appName }\ncameraList.sortBy { it.appName }\n//similarly for other lists...\n```\n\nTo implement the spinner item click functionality, we use the `onItemSelectedListener()` method and write our code in the following way. For each spinner value, we pass the corresponding list to the adapter and update the `tvCount` (TextView that displays the number of apps for every permission).\n\n:::tip\nJust a quick reminder: the spinner does not support `onClick()` events, so attempting to use `onItemClickListener()` will throw an exception.\n:::\n\n```kotlin\nrv_main_list.layoutManager = LinearLayoutManager(this)\n\nspinner.onItemSelectedListener = object : OnItemSelectedListener {\n override fun onItemSelected(\n parentView: AdapterView<*>?,\n selectedItemView: View,\n position: Int,\n id: Long\n ) {\n val text = parentView?.getItemAtPosition(position).toString()\n when (text) {\n permissionsArray[0] -> { //All apps\n adapter = AppAdapter(appList, applicationContext)\n rv_main_list.adapter = adapter\n tvCount.text = "${appList.size} apps found"\n }\n permissionsArray[1] -> { //Camera\n adapter = AppAdapter(cameraList, applicationContext)\n rv_main_list.adapter = adapter\n tvCount.text = "${cameraList.size} apps found"\n }\n permissionsArray[2] -> { //Contacts\n adapter = AppAdapter(contactsList, applicationContext)\n rv_main_list.adapter = adapter\n tvCount.text = "${contactsList.size} apps found"\n }\n\n //Similarly for other permissions...\n\n }\n }\n\n override fun onNothingSelected(parentView: AdapterView<*>?) {\n // your code here\n }\n}\n```\n\nI see that there are a lot of red lines in your **MainActivity** now. But don\'t worry, we\'ll implement our adapter next! It\'s a very basic adapter with the usual three override methods and a view binding from the `ViewHolder` class - nothing too complicated here. Here\'s the code for that:\n\n```kotlin\nclass AppAdapter(\n val items: MutableList<AppName>,\n val context: Context\n) :\n RecyclerView.Adapter<AppAdapter.ViewHolder>() {\n override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {\n return ViewHolder(LayoutInflater.from(context).inflate(R.layout.item_layout, parent, false))\n }\n\n override fun getItemCount() = items.size\n\n override fun onBindViewHolder(holder: ViewHolder, position: Int) {\n\n holder.appName.text = items[position].appName\n holder.icon.setImageDrawable(items[position].appIcon)\n\n }\n\n class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {\n val icon: ImageView = itemView.iv_icon\n val appName = itemView.tv_appname\n }\n\n}\n```\n\nThat\'s it! If you have implemented everything correctly, your app should be up and running and should look something like this!\n\n<p align="center" width="100%">\n <img\n src="/img/blog/permission-checker-app-in-android-studio-assets/permission-checker-live.gif"\n alt="Permission Checker app"\n />\n</p>\n\nCongratulations! You have successfully created your very own permission checker app using Kotlin and Android Studio. If you encountered any errors while running the app, you can check your code against my code on [GitHub](https://github.com/ishanknijhawan/Permission-Checker). Additionally, I have also implemented a click listener that, upon clicking an app item, redirects the user to that app\'s info so that they can manage the permissions from there.\n\nIf you found this article helpful and informative, please show your support by giving it a clap. Thank y
1ou for reading, and I look forward to seeing you soon in another article!'}]},d={authorsImageUrls:[void 0]},l=[{value:"<strong>Components of Android SDK</strong>",id:"components-of-android-sdk",level:2},{value:"<strong>Android SDK Build tool</strong>",id:"android-sdk-build-tool",level:3},{value:"<strong>Android Emulator</strong>",id:"android-emulator",level:3},{value:"<strong>Android SDK Platform-tools</strong>",id:"android-sdk-platform-tools",level:3},{value:"<strong>Android SDK Command Line-Tools</strong>",id:"android-sdk-command-line-tools",level:3},{value:"<strong>Installing Android SDK Tools</strong>",id:"installing-android-sdk-tools",level:2},{value:"<strong>Manual Android SDK installation</strong>",id:"manual-android-sdk-installation",level:3},{value:"I<strong>nstallation using Android CLI</strong>",id:"installation-using-android-cli",level:3},{value:"<strong>FAQs on Android SDK</strong>",id:"faqs-on-android-sdk",level:2},{value:"<strong>Get Started with Android SDK</strong>",id:"get-started-with-android-sdk",level:2}];function c(e){const n={a:"a",code:"code",em:"em",h2:"h2",h3:"h3",img:"img",li:"li",ol:"ol",p:"p",strong:"strong",ul:"ul",...(0,o.a)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.p,{children:"Android Software Development Kit (SDK) comes with several tools like APIs, Editors, and more to streamline the app development process."}),"\n",(0,i.jsx)(n.p,{children:"Additionally, you get more when using Android SDK:"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"Compabitibity with a suite of Android development tools in the ecosystem."}),"\n",(0,i.jsx)(n.li,{children:"Documentation and support resources to guide you through applications development"}),"\n",(0,i.jsx)(n.li,{children:"Easy access to additional functionalities like APs ( application programming interface) and debugging tools"}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"In this simple guide to Android SDK, you will learn its main components, how to install Android SDK tools, and the common questions other developers are asking about the kit."}),"\n",(0,i.jsx)(n.h2,{id:"components-of-android-sdk",children:(0,i.jsx)(n.strong,{children:"Components of Android SDK"})}),"\n",(0,i.jsxs)(n.p,{children:["If you are a beginner looking to develop Android applications, there are several Android SDK components you need to familiarize yourself with. You can access these components from the ",(0,i.jsx)(n.a,{href:"https://developer.android.com/studio/intro/update#sdk-manager",children:"SDK Manager"})]}),"\n",(0,i.jsx)(n.p,{children:"As an Android developer in the trenches already, take this simple guide as a recap of the component's updates. Also, keep tabs on the relevant use cases you are not maximizing to build the Android app faster."}),"\n",(0,i.jsx)(n.h3,{id:"android-sdk-build-tool",children:(0,i.jsx)(n.strong,{children:"Android SDK Build tool"})}),"\n",(0,i.jsx)(n.p,{children:"The SDK build compiles source code and app resources. It then packages them into APKs for developers to test, examine and ship Android apps."}),"\n",(0,i.jsxs)(n.p,{children:["Some notable ",(0,i.jsx)(n.a,{href:"https://developer.android.com/tools/releases/build-tools",children:"Android SDK build tools release notes"})," include the following:"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.strong,{children:"April 2023; General bug fixes and improvements"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.strong,{children:"February 2023: The update includes support for building with Android 14 preview APIs. Also, In the same month, core-lambda-stubs.jar version 33.0.0 issue fixing on MacOS versus Linux/Windows."})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.strong,{children:"November 2022: Fixing AIDL fails with build-tools 33.0.0"})}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["An example of an SDK build tool for packaging resources is the ",(0,i.jsx)(n.a,{href:"https://developer.android.com/tools/aapt2",children:"Android Asset Packaging Tool"})," (AAPT2). Both Android Studio and Android Gradle plugins use the build tool to compile resources into a binary format that is optimized for the Android platform."]}),"\n",(0,i.jsx)(n.h3,{id:"android-emulator",children:(0,i.jsx)(n.strong,{children:"Android Emulator"})}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.a,{href:"https://developer.android.com/studio/run/emulator",children:"Android emulator"})," allows your mobile to imitate the Android operating system (OS) into your PC. Although debugging is the main purpose of the softw
1are application, it also allows users to install Android apps on their computers and use them natively."]}),"\n",(0,i.jsx)(n.p,{children:"When testing and debugging your Android app on PC, it offers several advantages:"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"High fidelity"})," - You get access to almost all the capabilities of an Android device. This includes; access to Google Play Store, simulating network speed, incoming text messages & phone calls, other hardware sensors, and more."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Speed"})," When testing your app, it's hard to deploy it on a physical device. However, the emulator makes it faster and easier."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Flexibility"})," - The emulator comes with pre-defined configurations of Android devices (TV, phone, wear OS, and tablets)"]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"android_emulator_snapshots_featureimage3.png",src:t(39526).Z+"",width:"822",height:"652"})}),"\n",(0,i.jsx)(n.p,{children:"If you have already built an Android app and want to test it, here are some computer requirements to use an emulator in Android Studio for the best experience;"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"16 GB disk space"}),"\n",(0,i.jsx)(n.li,{children:"16 GB RAM"}),"\n",(0,i.jsx)(n.li,{children:"64-bit Windows,macOS, ChromeOS, or Linux operating system"}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"android-sdk-platform-tools",children:(0,i.jsx)(n.strong,{children:"Android SDK Platform-tools"})}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.a,{href:"https://developer.android.com/tools/releases/platform-tools",children:"Android SDK platform tools"})," interface with the Android ecosystem, majorly adb, and fastboot."]}),"\n",(0,i.jsxs)(n.p,{children:["If don\u2019t have the Studios installed, ",(0,i.jsx)(n.em,{children:"adb"})," is required for Android app development. On the other hand, ",(0,i.jsx)(n.em,{children:"fastboot"})," is needed if you want to unlock your device bootloader and flash it with a new system image."]}),"\n",(0,i.jsx)(n.p,{children:"The purpose of the unlocked bootloader requirement is to enable you to execute high-level customizations. However, you will still need the Android SDK platform tool installed for these reasons:"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"To check ADB and Fastboot connection"}),"\n",(0,i.jsx)(n.li,{children:"Booting IMG files"}),"\n",(0,i.jsx)(n.li,{children:"Flashing ZIP files"}),"\n",(0,i.jsx)(n.li,{children:"Directly booting your device to Android OS"}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"Some notable Android SDK platform tools release notes for 2023 have resulted to new ADB and Fastboot updates including:"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.strong,{children:"adb"})}),"\n",(0,i.jsxs)(n.li,{children:["Fixed zero-length packet sends for macOS ",(0,i.jsx)(n.a,{href:"https://issuetracker.google.com/issues/208675141",children:"(issuetracker: 208675141)"}),"."]}),"\n",(0,i.jsx)(n.li,{children:"Addressed unstable connectivity (MacBook high-speed cable): frequent adb disconnects."}),"\n",(0,i.jsx)(n.li,{children:"Improved error message for adb push with an insufficient number of arguments."}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.strong,{children:"fastboot"})}),"\n",(0,i.jsx)(n.li,{children:"Improved flashing: flashall will now skip reboots to userspace if it can."}),"\n",(0,i.jsxs)(n.li,{children:["Fixed zero-length packet sends for macOS ",(0,i.jsx)(n.a,{href:"https://issuetracker.google.com/issues/208675141",children:"(issuetracker: 208675141)"}),"."]}),"\n",(0,i.jsx)(n.li,{children:"Fixed flashing recovery.img resulting in the wrong AVB footer."}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"android-sdk-command-line-tools",children:(0,i.jsx)(n.strong,{children:"Android SDK Command Line-Tools"})}),"\n",(0,i.jsx)(n.p,{children:"Also known as Android Studio Command Line tools are a collection of utilities used to perform various tasks in Android app development."}),"\n",(0,i.jsxs)(n.p,{children:["If you do not want to install and ",(0,i.jsx)(n.a,{href:"https://developer.android.com/studio/intro/studio-config",children:"configure Android Studio"}),", the command line tools are perfect if only need a couple of packages for quick tasks."]}),"\n",(0,i.jsx)(n.p,{children:"The new command line tool replaces the previously known SDK tools with new features and is installed in the"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.em,{children:"android_sdk"}),"/cmdline-tools/",(0,i.jsx)(n.em,{children:"version"}),"/bin/ \xa0directory."]}),"\n",(0,i.jsx)(n.p,{children:"Some notable features you\xa0 can execute with Android SDK Command Line tools include:"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Compiler"})," - to create, compile and package your Android app"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Memory Monitor"})," - to monitor and analyze memory usage"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"ProGuard"}
1)," to shrink, obfuscate and optimize your code"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"APK Analyzer"})," - to analyze and optimize APKs (Android Package Kit)"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"ADB"})," - to manage your device with Android Debug Bridge"]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"installing-android-sdk-tools",children:(0,i.jsx)(n.strong,{children:"Installing Android SDK Tools"})}),"\n",(0,i.jsxs)(n.p,{children:["If you are using ",(0,i.jsx)(n.a,{href:"https://gradle.org/",children:"Gradle Build Tool"}),", the Android SDK is installed automatically with the latest version. Also, there are several ways to install Android SDK tools across different operating systems (Windows, Linux, and MacOS)."]}),"\n",(0,i.jsx)(n.h3,{id:"manual-android-sdk-installation",children:(0,i.jsx)(n.strong,{children:"Manual Android SDK installation"})}),"\n",(0,i.jsxs)(n.p,{children:["Using your computer or PC browser, open the ",(0,i.jsx)(n.a,{href:"https://developer.android.com/studio",children:"Android Studio"})," to set up the ",(0,i.jsx)(n.a,{href:"https://developer.android.com/about/versions/14/setup-sdk",children:"Android 14 SDK"}),".\xa0 This latest version will help you build and run your app on Android 14."]}),"\n",(0,i.jsx)(n.p,{children:"Within the Android Studio, these are the steps to install the SDK:"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["Click ",(0,i.jsx)(n.strong,{children:"Tools > SDK Manager"}),"."]}),"\n",(0,i.jsxs)(n.li,{children:["In the ",(0,i.jsx)(n.strong,{children:"SDK Platforms tab"}),", select ",(0,i.jsx)(n.strong,{children:"Android UpsideDownCake Preview"}),"."]}),"\n",(0,i.jsxs)(n.li,{children:["In the ",(0,i.jsx)(n.strong,{children:"SDK Tools"})," tab, select ",(0,i.jsx)(n.strong,{children:"Android SDK Build-Tools 34"}),". (This label may have a suffix such as ",(0,i.jsx)(n.strong,{children:"rc2"}),".)"]}),"\n",(0,i.jsxs)(n.li,{children:["Click ",(0,i.jsx)(n.strong,{children:"OK"})," to install the SDK."]}),"\n"]}),"\n",(0,i.jsxs)(n.h3,{id:"installation-using-android-cli",children:["I",(0,i.jsx)(n.strong,{children:"nstallation using Android CLI"})]}),"\n",(0,i.jsx)(n.p,{children:"You can also install Android SDK without necessarily taking the Android Studio path."}),"\n",(0,i.jsxs)(n.p,{children:["Google provides Android Command Line (CLI) tools. Assuming you already have the ",(0,i.jsx)(n.a,{href:"https://docs.oracle.com/en/java/javase/20/install/overview-jdk-installation.html#GUID-8677A77F-231A-40F7-98B9-1FD0B48C346A",children:"Java SDK installed"}),", here are the steps to install Android SDK without Android Studio."]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"Step 1:"}),"\xa0 Go to Android Studio and scroll to ",(0,i.jsx)(n.a,{href:"https://developer.android.com/studio#command-tools",children:"Command Line Tools only section"})," to download the zip file according to your operating system (Windows, Linux, or Mac)."]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"CLI tools.PNG",src:t(12376).Z+"",width:"1279",height:"419"})}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"Step 2:"}),"\xa0 After downloading the zip file and moving it to the home folder, you need to set up the CLI. First, create a directory to store the Android SDK. Open a new terminal and execute this code:"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.code,{children:"~ $ mkdir android"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.code,{children:"~ $ cd android"})}),"\n",(0,i.jsx)(n.p,{children:"Then we need to move and unzip the tools in the Android directory we have created:"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.code,{children:"~/android $ mv ~/commandlinetools-mac-6858069_latest.zip ./"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.code,{children:"~/android $ unzip commandlinetools-mac-6858069_latest.zip"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.code,{children:"~/android $ rm commandlinetools-mac-6858069_latest.zip"})}),"\n",(0,i.jsx)(n.p,{children:"The above directory will act as the $ANDROI_HOME so other libraries access it from the environment added ahead."}),"\n",(0,i.jsxs)(n.p,{children:["After unzipping the file, you should see a directory named; ",(0,i.jsx)(n.strong,{children:"cmdline-tools."})," Run the command and the new Android structure should look like this below:"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.code,{children:"android"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.code,{children:"\u2514\u2500\u2500 cmdline-tools"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.code,{children:"\u2514\u2500\u2500 tools"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.code,{children:"\u251c\u2500\u2500 NOTICE.txt"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.code,{children:"\u251c\u2500\u2500 bin"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.code,{children:"\u251c\u2500\u2500 lib"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.code,{children:"\u2514\u2500\u2500 source.properties"})}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"Step 3:"}),"\xa0 Add $ANDROID_HOME to $PATH by opening \xa0",(0,i.jsx)(n.strong,{children:".zshrc"})," or ",(0,i.jsx)(n.strong,{children:".bash_profile"})," in your preferred terminal file editor (nano or vim) and the code below;"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.code,{children:"export ANDROID_HOME=$HOME/android"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.code,{children:"export PATH=$ANDROID_HOME/cmdline-tools/tools/bin/:$PATH"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.code,{children:"export PATH=$ANDROID_HOME/emulator/:$PATH"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.code,{children:"export PATH=$ANDROID_HOME/platform-tools/:$PATH"})}),"\n",(0,i.jsx)(n.p,{children:"After adding the code, save the file, then open a new terminal window and type the following command and hit enter/return."}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.code,{children:"$ sdkmanager"})}),"\n",(0,i.jsx)(n.p,{children:"For a successful setup, you will see the following progressbar:"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.code,{children:"[== \xa0 \xa0 \xa0 \xa0 \xa0 \xa0 \xa0 \xa0 \xa0 \xa0 \xa0 \xa0 \xa0 \xa0 \xa0 \xa0 \xa0 \xa0 ] 6% Fetch remote repository\u2026"})}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"Step 4:"})," On following the command, you will get to see the Android SDK tool, build tools, platform tools, NDKs, and emulators."]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.code,{children:"$ sdkmanager --list"})}),"\n",(0,i.jsx)(n.p,{children:"To install the page, you want to copy\xa0 the package name and install:"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.code,{children:'$ sdkmanager --install "package_name"'})}),"\n",(0,i.jsx)(n.h2,{id:"faqs-on-android-sdk",children:(0,i.jsx)(n.strong,{children:"FAQs on Android SDK"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"What is APK and SDK?"})}),"\n",(0,i.jsx)(n.p,{children:"The difference between APK ( application package kit) and SDK (software development kit) is that the APK files are used to distribute and install Android apps while SDK is used by developers to build apps for particular operating systems (e.g. Android, Linux, Windows, or Mac)."}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"Which Android SDK is most used?"})}),"\n",(0,i.jsx)(n.p,{children:"The most used Android SDK is Firebase. Firebase is a Google application development platform for quick and high-quality app development. It provides detailed documentation and cross-platform SDKs to help build and ship apps on C++, iOS, Unity, Android, and more."}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"Is Android Studio and Android SDK the same?"})}),"\n",(0,i.jsx)(n.p,{children:"Android Studio is primarily classified as an Integrated Development Environment (IDE) while an Android SDK is a software development kit with comprehensive tools including; libraries, debuggers, documentation, and more."}),"\n",(0,i.jsx)(n.h2,{id:"get-started-with-android-sdk",children:(0,i.jsx)(n.strong,{children:"Get Started with Android SDK"})}),"\n",(0,i.jsx)(n.p,{children:"This beginner\u2019s guide to Android SDK offers the key components and installation steps to beginner Android developers. Additionally, you get resources to the latest Android SDK release notes for new feature installations and updates."}),"\n",(0,i.jsx)(n.p,{children:"Use these Android SDK tools to streamline your app from development, testing, and shipping the best to the end users. Until next time, keep learning, building, and deploying Android applications."})]})}function p(e={}){const{wrapper:n}={...(0,o.a)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(c,{...e})}):c(e)}},12376:(e,n,t)=>{t.d(n,{Z:()=>i});const i=t.p+"assets/images/CLI_tools-526b2a68e5f52b45e875c9d95528f700.png"},39526:(e,n,t)=>{t.d(n,{Z:()=>i});const i=t.p+"assets/images/android_emulator_snapshots_featureimage3-9b3d3b348a82e8a508650d5e8419733b.png"},11151:(e,n,t)=>{t.d(n,{Z:()=>s,a:()=>r});var i=t(67294);const o={},a=i.createContext(o);function r(e){const n=i.useContext(a);return i.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function s(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:r(e.components),i.createElement(a.Provider,{value:n},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.