Skip to content
All Posts

Setting Up an Android Development Environment

A setup walkthrough for Android Studio, SDK packages, VirtualBox, and Genymotion on Ubuntu 12.04.

Because Google services were blocked, setting up an Android environment was fairly troublesome. What is blocked varies by time and location, so rely on your actual environment. I used Ubuntu 12.04 with kernel 3.11.0-26-generic; OS X is similar. The links at the end provide relevant software and packages.

Downloading and configuring Android Studio

Download the latest version and run ./studio.sh under android-studio/bin. Android Studio then connects to retrieve SDK information and may remain stuck on the download screen, so first change its configuration to allow startup. On OS X the SDK may download quickly enough to finish during initial startup.

Add this line to the end of idea.properties in the bin directory:

disable.android.first.run=true

Save the file and restart Android Studio.

Select Configure -> Project Defaults -> Project Structure and set the Android SDK and JDK paths. Keep the SDK beside the Android Studio installation rather than inside it: an in-place Android Studio update may fail when another directory under the installation is in use.

If installation reports “unable to run mksdcard sdk tool,” install these dependencies:

Terminal window
$ sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 lib32stdc++6

Open Settings from the File menu, search for auto import, and enable every option. Imports will then be added automatically and sorted alphabetically.

Installing packages and tools

The required packages include the Android SDK, SDK Tools, Platform Tools, and Build Tools:

  • Extract SDK platforms into your SDK path/platforms.
  • Extract SDK Tools into your SDK path/tools; these include DDMS and Draw 9-patch.
  • Extract Platform Tools into your SDK path/platform-tools; these include ADB and Fastboot.
  • Extract Build Tools into your SDK path/build-tools; these are required to build applications.

This is cumbersome. If you have a VPN, use Android SDK Manager instead.

Unless you develop and test on a physical device, install an Intel Atom image with HAXM or use Genymotion; otherwise the emulator is unbearably slow. My earlier article covers Intel’s Android acceleration tools. For Genymotion, continue below. I recommend either Genymotion or a physical device.

Using Genymotion

Register on the Genymotion website and download the Linux version. Genymotion requires VirtualBox and cannot initialize or start without it.

Download the latest VirtualBox 5.0 package from the official website. Do not use an APT repository; when I tried, the repository could not be found. Download the DEB package and install it directly:

Terminal window
$ dpkg -i virtualbox-5.0.deb

Then run ./genymotion.bin to install Genymotion. If that fails, run sudo chmod +x genymotion and try again.

Android Studio requires the Genymotion plugin. Open File -> Settings, select Plugins, search for Genymotion, and install it. The plugin is under 1 MB and downloads quickly. After restarting Android Studio, a red phone-shaped Genymotion icon appears at the far right of the toolbar.

Genymotion icon in the Android Studio toolbar

Click the icon to create a virtual device. You must sign in with the account registered when downloading Genymotion. Login occasionally reports unknown generic error; it usually clears shortly afterward and may be a network issue.

To debug an application with Genymotion, start the virtual device first. After the app builds, Android Studio asks which device to use; select the running device.

The source image is no longer available: original image URL

References and mirrors


Originally published on SegmentFault.