Android SDK

From RootzWiki
Jump to: navigation, search

The Android Software Development Kit is a package created by Google to support the development of apps for the Android ecosystem.


The Android SDK allows for integration with programming IDEs such as Eclipse, interaction with testing devices via ADB, as well as emulation of various platforms and software/hardware configurations via the Android Emulator. Physical device testing is highly recommended as emulation of the ARM processor on an x86 processor is extremely slow, especially with Honeycomb and Ice Cream Sandwich, which make use of hardware graphics acceleration. Further details are available on the Android SDK website.

Outside of app development, its most common use is for two programs it includes: adb and fastboot.


ADB, or Android Debug Bridge, is a multi-purpose tool created to allow interaction with Android devices over TCP/IP and USB. It allows for the sending (push) or receiving (pull) of files, pulling of system logs (logcat), starting a terminal (shell), mounting the system partition as read-write (remount), forwarding socket connections (tunneling), installing and uninstalling APKs, and backing up or restoring data.

ADB runs as a client-server configuration, with a server that maintains the connection to a device, and a client that the user sends commands through. This is important, because if ADB is not installed properly on a Linux-based operating system, the ADB server will have to be started prior to use with sudo adb start-server.

ADB does not require root access, except with the adb remount command.

The following are commands usable via ADB:


A simple diagnostic command, adb devices will list the serial numbers of any devices the ADB server is currently connected to.

Note: If multiple devices are currently connected, use the -p (serial number) flag to specify which device you wish to execute the command to.


Pushing is used to send files from the computer, to a connected Android device. The syntax is very simple: adb push (local file/folder) (device file/folder)

For example, to push file.bin from the folder that the command prompt is currently in, to the directory /data/local on a device, one would simply use adb push file.bin /data/local/


Pulling is similar to pushing but operates in reverse: It copies files from the device, to the computer. adb pull (device file/folder) (local file/folder)

Specifying the local file and/or folder name is optional. If omitted, whatever directory the command prompt is currently in will be used instead, and file names will stay the same as they were on the device.


Logcat is one of the most commonly used ADB commands. It outputs the system log from the connected device to the terminal window in real-time. For easier bug reports, the logcat can be outputted to a file: adb logcat > logcat.txt

Frequently developers will ask for a logcat if an app has force-closed (created an ANR or App Not Responding dialog) or experienced another bug. The easiest way to is either provide them with the raw logcat file, or to copy the contents of the file to a public pastebin such as It is recommended that if you do so, specify the Paste Exposure as Unlisted, and have the paste expire after a reasonable amount of time. Otherwise, your paste may be logged by Google, and could potentially reveal sensitive information if another app has logged such data.

Alternatively, the adb bugreport command can be used to get additional data.


The adb shell command can be used to start an interactive shell session on the device. However, it will be limited by the capabilities of the command prompt it is open in, and the default shell on the device.

Alternatively, adb shell can be used to specify a command to execute on the device. For example, to set the permissions on a file to be executable and readable by all users, and writable by the owner: adb shell chmod 0755 /data/local/file.bin


adb remount can be used to re-mount the /system partition (which contains the Android system software) as writable by ADB and other root-using applications. However, it will not function if the system partition is protected by the bootloader (NAND lock), if root access is not available, or if root is not available by default to an adb shell session.

The manual method of adb remount is:

  1. adb shell
  2. su
  3. mount -o remount,rw /system
  4. exit


ADB can also be used to install APK (Android application packages) files on a device: adb install MyAmazingApp-1.0-signed.apk

Various flags are available to specify additional options, such as the -r flag to reinstall an app and not remove its data, or -s to force installation to an SD card or external storage (if applicable).

It can likewise be used to uninstall an app via its package name: adb uninstall com.example.amazingapp. The -k flag is available to specify that the app's cache and data should not be erased.


Fastboot is a tool used to install raw partition images on Android devices via their bootloader, as well as interact with the bootloader directly, performing actions such as unlocking, deleting contents of permissions, booting off of partition images without overwriting installed partition data, and performing an RUU (ROM Update Utility) task. Like ADB, the -s (serial number) flag is available to specify what device Fastboot should communicate to if multiple devices are detected. However, unlike ADB, Fastboot can only operate via USB due to the fact that a device's bootloader does not run the Linux kernel, nor Android, meaning that it cannot manage nor connect to a WiFi, cellular, or other wireless network.


Similar to ADB Devices, fastboot devices shows all of the devices Fastboot recognizes as being in their respective fastboot modes, usually an option within the bootloader.


fastboot flash is used to install a raw image to a partition on a device. It can be used to flash kernels, custom recoveries, radio basebands, bootloaders, or entire system or data partitions. Its usage is simple: fastboot flash (partition) (file).

For example, to flash ClockworkMod Touch Recovery for the Samsung Galaxy Nexus (toro), one would cd to the directory which the image file has been downloaded, and run fastboot flash recovery recovery-clockwork-touch-

Some common partition names: recovery, boot, radio, radio-cdma, bootloader, system, userdata, cache, and wimax.


fastboot erase is very straight-forward: It erases the specified partition. Example: fastboot erase cache will erase the contents of the /cache partition.


fastboot boot is one of the most useful tools for kernel or custom recovery developers. It allows the device to boot off of, but not install, a custom kernel or recovery. This way, if there is a problem with the kernel or recovery, the device can simply be rebooted, and it will revert to the installed version.

Syntax is very simple: fastboot boot (file) where (file) is the kernel or recovery image (also sometimes called a zImage). It must be in the same folder that the command prompt is currently open in, or else the path to it must be specified (eg, fastboot boot ~/Downloads/kernel.img


OEM commands are proprietary commands created by the device's manufacturer. The most famous of which is fastboot oem unlock which unlocks a Nexus device's bootloader to allow the flashing of partitions, and its opposite, fastboot oem lock which re-locks the bootloader. HTC also uses the fastboot oem command for use with their HTCDev bootloader unlocking program.


The following is a guide to install the Android SDK and add its binaries to the system $PATH.

Device Setup

On your device, open the system settings, and enable USB Debugging:

Android 1.x-2.x

  1. Applications
  2. Development
  3. USB debugging

Android 4.x

  1. System
  2. Developer options
  3. USB debugging


A video demonstration is available for Windows 7.



Download the Android SDK installer from the SDK website. Click the "Download for Other Platforms" and then make sure to download the EXE file (not the ZIP) from the SDK Tools Only section. As of 06 December, 2012, the latest version is release 21.


  1. Install the EXE like any other program, using the default options.
  2. When it is done, open the Android SDK Manager in your Start menu if not given the option to launch it at the end of the installation.
    On Windows Vista and later, you may need to open the android-sdk folder (located at C:\Program Files (x86)\Android\android-sdk or C:\Program Files\Android\android-sdk on a 32-bit Windows installation, right-click SDK Manager.exe, select Properties, the Compatibility tab, Change settings for all users, then check Run this program as an administrator. Click OK then OK and close the android-sdk window.
  3. Make sure that only Android support package, Google USB Driver package, Android SDK Tools, and Android SDK Platform-tools are checked, and install/update them through the on-screen prompts. You may be asked to Accept the licensing terms of the packages.


  1. Once the Android SDK has been installed and its components updated, close the SDK Manager.
  2. Right-click on My Computer (Computer or your computer's name in Vista or later) and select Properties.
    Vista and later: Select Advanced system settings on the left.
  3. Select the Advanced tab, then click the Environment Variables... button.
  4. Under the System variables, scroll down and select Path, then click Edit....
  5. Add the following to the end of the Variable value field:
    Windows XP: ;C:\Program Files\Android\android-sdk\tools\;C:\Program Files\Android\android-sdk\platform-tools\
    Windows Vista and later:
    Replace YOURUSERNAME in the following lines with your Windows username
    32-Bit: ;C:\Program Files\Android\android-sdk\tools\;C:\Program Files\Android\android-sdk\platform-tools\
    64-Bit: ;C:\Users\YOURUSERNAME\AppData\Local\Android\android-sdk\tools\;C:\Users\YOURUSERNAME\AppData\Local\Android\android-sdk\platform-tools\
  6. Click OK, OK, and OK to close the Advanced settings.

To test that the installation was successful, open a command prompt (Press the Windows key and R at the same time, type cmd and hit Enter) and type the command adb start-server. If it runs without any errors, then you have installed the Android SDK successfully!



  • Root access
  • Latest Java Development Kit (JDK) installed
    OpenJDK may work, but is not recommended if you plan on compiling Android in the future. The official JDK is preferable.
  • Ubuntu installation
    Other distros will work, but this guide is designed for Ubuntu.


Download the Android SDK package from the SDK website. As of 08 April, 2012, the latest version is release 17.


Open a Terminal and run the following:

  1. cd ~/Downloads
  2. tar xzf android-sdk*.tgz
  3. sudo mv android-sdk-linux /usr/local/android-sdk-linux/
  4. sudo chown -R root:root /usr/local/android-sdk-linux/
  5. sudo chmod -R a+r /usr/local/android-sdk-linux/
  6. sudo chmod a+x /usr/local/android-sdk-linux/
  7. sudo chmod a+x /usr/local/android-sdk-linux/*/
  8. cd /usr/local/android-sdk-linux/tools/
  9. sudo ./android

When the Android SDK Manager opens, allow it a moment to fetch the repositories. Once it has, check only the Tools folder and its contents, then click Install. Check Accept All and Install, then allow the Manager time to install the packages. When it's done, close the Manager.


Run the following commands to add the Android SDK tools to your PATH:

  1. sudo su -
  2. echo "export PATH=\"$PATH:/usr/local/android-sdk-linux/tools/:/usr/local/android-sdk-linux/platform-tools/\"" >> /etc/profile
  3. exit
  4. source /etc/profile
  5. adb start-server

If you receive no errors, then congratulations, your PATH is configured! Go ahead and reboot your computer (logging out and logging back in may be sufficient) in order to force the updated PATH to fully take effect for all terminal sessions and all users.

udev Rules

Adding udev rules will result in no longer needing to start the ADB server as root. First, sudo to a root shell: sudo su -

Just run the following commands as root. If there's no errors, you're done!
wget; chmod a+x; ./; rm



  • Administrator (root) access
  • Latest Java Development Kit (JDK) installed
    OpenJDK may work, but is not recommended.
  • Intel CPU (No PowerPC)




External Links

Personal tools
Google AdSense