Wednesday, August 07, 2013

Using the Android SDK without Eclipse

Although Android development is supposed to be easier with Eclipse because the SDK was developed for use with it, I usually find that I'm struggling with the IDE after a while. So, I'm always looking for an alternative that's less stressful to use.

I've opted to use gEdit as my text editor. Vim/Emacs are good options, too. In fact, they'd probably make better options since they're much more customisable. But Vim seems to have a pretty steep learning curve so I'll just start with the more basic gEdit. gEdit can do syntax highlighting and GUI-based Copy/Cut/Paste operations are 2nd nature to me. It's much easier for me to navigate.

Installing the Android SDK

Android SDK website
To develop for Android, we'll of course be needing the Android SDK. So head over to the Android SDK website to download the latest SDK tools. Do not download the ADT bundle. That's for Eclipse.

You'll also need to install OpenJDK and Apache Ant. Apache Ant on Ubuntu 13.04 is version 1.7 while the Android SDK site recommends 1.8 or later. I've tried it and so far it works so no worries there.

~$ sudo apt-get install openjdk-6-jdk ant
~$ cd Downloads
~/Downloads$ tar zxvf android-sdk_r22.0.5-linux.tgz
~/Downloads$ mv android-sdk-linux/ ~/.android-sdk-linux/

To make it so you can run the Android SDK Manager and adb from anywhere, you'll want to change your PATH. Open up ~/.pam_environment using your favorite text editor and add a PATH entry. You'll need to know what's on your system-wide PATH and include those entries as well.

Here's how to see what's currently in PATH.

~$ $PATH

You should see something like this.

bash: /usr/lib/lightdm/lightdm:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games: No such file or directory

Copy everything between bash: and No such file or directory and include that in your per-user PATH along with platform-tools/ and tools/ from the Android SDK folder. It should look like this.


The settings will take effect the next time you login to your desktop.

Keep in mind that if there's any changes to system PATH you may need to manually add those changes to ~/.pam_environment or those changes won't have any effect on your account.

Installing Android SDK components

Once that's setup you'll want to run the SDK Manager to download the SDK Platform, emulator system image, documentation and various components you'll need to do development work.

~$ android sdk


~$ android

Either is fine. They do the same thing.

The Android SDK Manager
You'll also want to create an emulator to test your apps using Android AVD Manager.

~$ android avd

Android AVD Manager

Create the virtual device using the AVD and you're ready to do. It's recommended that you create one that runs the latest Android version available. This way you can test out every possible feature in Android.

Now we're ready to start developing for Android. The Android SDK website provides a tutorial to get started on Android development.