Android Development Setup under Ubuntu Linux


So you want to be an Android developer, and you have an Android phone and an Ubuntu Linux computer ready. Rejoice, all you need is out there. With the Android SDK (including adb), the Android Studio (or Eclipse + ADT before 2015) IDE and some Linux twiddling, we will get you ready.

1 Setting up the SDK

First we want adb [doc] (android debug bridge) for diagnostics. Unfortunately, in 2020 you cannot download the Android SDK directly anymore, instead we have three choices: Debian repository, command tools or Android Studio. If you just want to connect your phone by USB, the repo is easiest:

apt-get install adb android-sdk-platform-tools-common

For the second option, Google really doesnt want us to go headless [forum] [blog] but we can download the command tools [doc] (85MB) with the included sdkmanager [doc] put carefully into a specifically named android-sdk directory. We only need to download the build tools [rel] (1.1GB) which apparently include the platform tools [rel]; the platform [rel] comes later.

export JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64 # ... or so
export ANDROID_SDK_ROOT=/opt/android-sdk

unzip commandlinetools-linux-*

cd cmdline-tools # thanks, Google
mkdir latest     # for making this
mv * latest      # harder than necessary
cd latest/bin    # and confusing to boot

./sdkmanager --list
./sdkmanager "build-tools;30.0.3"
./sdkmanager --licenses # just to make sure we didnt
./sdkmanager --update   # miss something "important"
./sdkmanager --list_installed

cd $ANDROID_SDK_ROOT/platform-tools
./adb version

And finally, the third option by GUI is to install Android Studio IDE where upon starting bin/, a wizard dialog will download the Android SDK to a location of your choice; alternatively an existing SDK path can be specified. After that you go Tools->SDK Manager, where you can see that "the SDK" comprises platform and tools.

As of 2021, platform API Level 29 is the minimum version for app deployment in the GPlay store [docs]; the open source-only F-Droid store has no such limitations. The wizard above will install the newest platform, so you have to remove it and add API 29 yourself.

2 Setting up the Hardware Phone

This is a multi-step thing [doc]. First, get your phone ready, go to Settings->About phone and click Kernel version 7 times (seriously, I am not making this up) to get "Developer mode". Then activate Security->Unknown Sources and Development->USB Debugging, to be found in Settings->Applications (Android 2), Settings->Security (Android 4), Settings->Other->Developer options (Android 11) or similar. Restart your phone for good measure.

Second, on your Linux machine, make sure that the kernel gives you access to plugged USB devices, and that the device is recognized.

nano -w /etc/group

nano -w /etc/udev/rules.d/51-android.rules
    SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666", GROUP="plugdev"

... where idVendor or alternatively idProduct must match your phone type [list], e.g. productId=9139 for YotaPhone 2 or vendorId=109b for HiSense (e.g. A5 Pro CC). If you installed by apt-get, the rules list should already be sufficient.

As root, systemctl restart udev, and re-login if you were not yet member of group plugdev before. Finally, plugin the phone via USB and go:

adb kill-server  # just to be sure
adb start-server # might require root

adb devices

Your phone should be visible in the adb output, and with adb shell you should be able to start all kinds of activity [xda1] [xda2]. And with the next app start, Android Studio (or Eclipse until 2015) should ask you whether you want the emulator or the physical phone.

3 Setting up the Emulation

You will be tempted to think this was it, but we still need two more things things, namely install an Android platform version (e.g. API Level 29), and create an emulated phone (or tablet) [docs].

If you have Android Studio installed, go to Tools->AVD Manager and create a suitable device by click-fest. Otherwise we use our command tools again:

cd $ANDROID_SDK_ROOT/cmdline-tools/latest/bin
./sdkmanager --list_installed       # 1.1GB
./sdkmanager "platforms;android-29" # 1.3GB
./sdkmanager "system-images;android-29;default;x86_64" # 4.4GB

./avdmanager create avd --name myphone-29 --package "system-images;android-29;default;x86_64"
./avdmanager list avd # still 4.4GB

... but you should probably only do that for integration into another tool chain; otherwise better stay with Android Studio from here. One last thing is the emulator running faster with KVM enabled [doc], which in turn requires hardware virtualization in your UEFI (or BIOS) firmware [blog].

apt-get install cpu-checker

# ... and if it is not ok:
apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils

... and this should accelerate the otherwise pretty slow emulation considerably.

4 Setting up the Development Environment

We assume a downloaded and installed Android Studio [dl] (or Eclipse with Android Development Tools before 2015).

If you followed the instructions above, there is really not much to set up anymore: We have the SDK tools = build + platform tools (newest), one platform (API 29), a system image (API 29) and derived emulated device (API 29). The SDK tools exist only once but we can have multiple platforms.

Confusing as this multitude of tools is [forum], we are in for something worse: app build automation with Gradle [doc] or previously Maven [forum] [cmp], both of which have a dynamic dependency graph that is updated automatically in the best case, and produces labyrinthine failures otherwise. Good luck.

From the development setup side, we are done though. Now create your first project and try your hand at app setup...

5 Eclipse (2010)

Once upon a time before 2015, the first version of this guide had Eclipse + ADT as IDE; ANDROID_SDK_ROOT was called ANDROID_HOME back then.

Setting up the SDK

You will want an Eclipse (probably the JEE version) and then you need install the ADT plugin (android developer tools, not to be confused with the previously mentioned Android SDK) from Google. You can do without Eclipse, but it is an eternal pain in the butt. Open the Eclipse update manager and get everything from

After Eclipse restart, go via menubar to Window->Preferences->Android and set the ANDROID_HOME location. It might also be a smart idea to set ANDROID_HOME in ~/.bashrc or wherever you keep your variables.

One eternal source of disdain is the fact that source code is not installed alongside the android.jar package. As of 2011, you can solve this via the Eclipse update manager. Install everything from and you can F3 your way through the Android source.

Setting Up the Emulation

In Eclipse menubar, choose Window->Android SDK Manager and install the platform versions you like.

After that, again in Eclipse menubar, choose Window->AVD Manager (android virtual device) and create an emulated phone. You will probably want to have a 20 MB SD card emulated in there.

Now in Eclipse, create a new Android project. It will be a stub with one text view only. Rightclick on the project, choose Run As->Android Application and the emulator will take a long time to come, while your application will be pretty quick. Do not close the emulator between deployments; a new install will overwrite the old one, and keeping the emulator open will save you a lot of time.

... and that was when APK were built locally by Ant and not by some byzantine, always-online Gradle dependency graph that only Google understands. On the plus side, the IDEA [dl] base of Android Studio makes for a much smoother and more interactive IDE than Eclipse ever was. And the source code of the Android libraries is available too.


So this was the short ride through Android development setup. To take your time, read up more details, and start the actual development, please follow the Android developer guide. Most of all, have fun coding!

EOF (Apr:2021)