Additional helpful stuff
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:
sudo apt-get install android-tools-adb
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:
export PATH=${PATH}:/home/rajamalw/sdk/platform-tools/
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:
adb devices
This command displays all the devices that are attached to your PC. It would return an output similar to the following:
List of devices attached ZX1B325BRZ device
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:
adb install myappname.apk
The following adb
command can be used to copy the image.png
file from the SD card to your PC:
adb pull /sdcard/image.png
The following command can be used to copy the image.png
file from your PC to the root of your SD card:
adb push image.png /sdcard/
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:
adb logcat
The following command lands you in the shell using which you can execute some common Linux commands on your device:
adb shell
Configuring JAVA environment variables
While starting Android Studio, you may get a JAVA_HOME is not set error. Let me show you how to fix this error.
- Open Control Panel and select System.
- Then, go to System protection | Advanced | Environment Variables... | System variables.
- Then, create a new variable and provide a variable name as
JAVA_HOME
and a variable value as a path to your Java installation.
Android API levels
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.