I wanted to try write some Android apps. I don't wish to use Eclipse. I don't need it or nor do I want it. Sadly most of the guides I found on the internet for starting out with Android apps uses Eclipse.

With this in mind I set off to get the Android SDK and emulator+tools running stand alone, allowing me to use vim as my editor.

The instructions are written for Gentoo, however they could be used by any distro. In Gentoo you also need to have "dev-java/oracle-jdk-bin" installed "or some JDK" not the JRE.

Firstly you need to download a copy of the Android SDK Select "Use an Existing IDE" and click the "Download the SDK Tools for Linux" and save it somewhere. I saved it under /opt as I plan to unpack it in /opt later on. I am using the version "android-sdk_r22.6.2". Do not download the "ADT Bundle for Linux", that is the whole SDK + Eclipse.

Once the download is done you need to extract the tarball somewhere. I extracted mine into "/opt/android-sdk/" this allows me to have more then one version of the SDK installed.

Now that the SDK has been extracted you need to install some of the tools and an Android image. To do this change into the extracted SDK source change into the "tools" folder. For me this is located at "/opt/android-sdk/android-sdk-linux/tools/".
You need to run the android application "./android" this should launch a GUI.

Android versions

Leave the top defaults and select one or more android versions you wish to install an emulator for. Leave the selected "tools" packages installed I also selected "Android 4.4.2 (API 19)" to install.

Once the install is done, exit the GUI application. I had a little bug hear, where the "tools" folder appears empty after I closed the GUI application after the install. To fix this change up one directory then back into the tools directory.

Next you need to configure an image profile for the emulator. You can configure more then one and run different versions of android. Run the "android" application under the "tools" directory again. This time select the menu option "Tools" then "Manage AVD". Then Click "New..." Configure a new AVD with the settings you see in the image below.

AVD settings

Once your done click "OK". You can add more AVD's or close off the android tool at this point. The AVD name you set is importation, so make note of it.

Now its time to create your first project template. This template will create all the files you need to start writing your first app. Change back into the "tools" folder and run the following command. The command to create this looks like this :

./android create project --target 1 --name $YOUR-PROJECT-NAME --path /path/to/new/project --activity MainActivity --package $PACKAGE-NAME

Lets take a look at some of the above command line options.

  • --target , leave this set to 1. (You can view targets with ./android list)
  • --name , A name for your project. Eg hello-world
  • --path , Where to save the new project
  • --activity , Leave this set to MainActivity
  • --package , the name of the package in the format "hk.horan.appname" for example

Now that you have created your project and an emulator its time to launch the emulator. Change back into the "tools" directory and if you are on a 64bit machine you can run the following command :

LD_PRELOAD=/opt/android-sdk/android-sdk-linux/tools/lib/lib64OpenglRender.so ./emulator64-arm @test -gpu on

This command will pre-load the GPU assisted library as well, to increase performance of them emulator. You will need to change the LD_PRELOAD path to point to your copy of the lib64OpenglRender.so library. You will also notice the "@test" this is the name of the AVD you set when you created the AVD emulator. I had called mine test, replace "test" with the name of your AVD.

You can now start to write some code. No need to keep the emulator open, but you can if you like.