Let's see some things that will help in app development such as ADB, configuring the Java environment variable, and API levels.
Using Android Debug Bridge
Android
Debug Bridge (ADB) is an inbuilt command-line tool, which helps us communicate with our virtual device or physical device.
The ADB tool can be found within our SDK directory. It is available at sdk | platform-tools.
Ubuntu users can easily install ADB by using the following command and directly accessing ADB from the command line:
To access ADB from any directory, if you are using older versions, you need to export the path of the adb
directory. It can be done by using the following command:
Here, I have given the path of my adb
directory. To validate it for all the terminal sessions, you can add this line in the .bashrc
file located in your home directory.
For detailed information on ADB, refer to the official documentation at http://developer.android.com/tools/help/adb.html.
Let's see some of the adb
commands we mostly use:
This command displays all the devices that are attached to your PC. It would return an output similar to the following:
To work with your own physical device, you must enable the USB Debugging option in the Developer options.
To install an APK on my device via ADB, I used the following command. Replace myappname
with the name of the APK:
The following adb
command can be used to copy the image.png
file from the SD card to your PC:
The following command can be used to copy the image.png
file from your PC to the root of your SD card:
The following is the most important command for Android developers, which helps them to debug the app, and to know why and when it is crashing. This displays the logs from the device. The IDE shows the logcat messages too, both in Android Studio and Eclipse with the ADT plugin:
The following command lands you in the shell using which you can execute some common Linux commands on your device:
This is just for reference and to give you an idea about API levels. Each API level corresponds to each framework revision of Android, starting from API level 1 to API level 22. Android Lollipop 5.1, which is the latest API level, corresponds to API level 22. KitKat 4.4 corresponds to API level 19, while Gingerbread corresponds to API level 8 and 9.