User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active
 

While I've gone through the steps of installing the Android SDK in multiple systems (Linux & Windows) as part of my daily job, I've found that those who are new to the Android world might found themselves in a sea of links and options to follow. This article describes a simple list for what to install and configure in order to setup your Android SDK environment.

While I've gone through the steps of installing the Android SDK in multiple systems (Linux & Windows) as part of my daily job, I've found that those who are new to the Android world might found themselves in a sea of links and options to follow. This article describes a simple list for what to install and configure in order to setup your Android SDK environment.

 

What is Android?

Android is an OS that has been recently adopted by many companies worldwide and is currently used in many of the cell phone, tablets and other specialized devices that we use today. Google claims that currently there are more than 600,000 apps in the Google Play market available (free and paid).

 

Why Develop on Android?

Reasons are many, but if you don't know why you need to develop in Android, then this article is most probably not for you. This article does not extend on the philosophical view of wars between OS.

 

Software Installation

  • Java is the core of the Android application development is based on Java, thus we need the Java Development Kit in order to compile and package applications.
    1. Download Java SDK for Linux. At the time this article was written the latest JDK version was 7u9
      http://www.oracle.com/technetwork/java/javase/downloads/index.html
    2. Extract the content of the downloaded file in /opt/java/current:
      $ mkdir -p ~/devel/java
      $ tar -zxvf ~/Downloads/jdk-7u9-linux-i586.tar.gz -C ~/devel/java/
      $ chown -R `whoami`.`whoami` ~/devel/java/jdk1.7.0_09
      $ ln -s ~/devel/java/jdk1.7.0_09 ~/devel/java/latest
    3. Update your PATH enviromental variable to include the JDK bin directory:
      $ sed '/^JAVA_HOME/d' -i ~/.bashrc && echo 'JAVA_HOME=~/devel/java/latest' >> ~/.bashrc
      $ P=$(awk -F= '/PATH/ {print $2}' ~/.bashrc) && sed '/^PATH/d' -i ~/.bashrc && echo -e "PATH=$P\nexport JAVA_HOME PATH" >> ~/.bashrc
  • The Eclipse IDE is the development tool of choice for developing code for Android.

    1. Download the Eclipse IDE for Java developers. At the time this article was written the latest Eclipse IDE version was Juno SR1.
      http://eclipse.org/downloads/
    2. Extract the content of the downloaded file in /opt/eclipse:
      $ mkdir -p ~/devel/eclipse
      $ tar -zxvf ~/Downloads/eclipse-java-juno-SR1-linux-gtk.tar.gz -C ~/devel/
      $ chown `whoami`.`whoami` ~/devel/eclipse
  • Android SDK is the set of libraries and that allows the developer to build code against a particular OS version, and in the case you don't have a real device it also provides the emulator where to test your application.

    1. Download the Android SDK from the android developer site. Since we'll go thought the process of setting the whole environment, make sure not to download the ADT bundle. At the time this article was written the Android SDK version was r21:
      http://developer.android.com/sdk/index.html
    2. Extract the content of the downloaded SDK:
      $ mkdir -p ~/devel/android
      $ tar -zxvf ~/Downloads/android-sdk_r21-linux.tgz -C ~/devel/android
      $ chown `whoami`.`whoami` -R ~/devel/android/android-sdk-linux
      $ sed 's#^PATH=\(.\)#PATH=~/devel/android/android-sdk-linux/platform-tools:\1#' -i ~/.bashrc
  • Install the Android Development Tools (ADT) plugin for Eclipse. This plugin provides an integrated environment in which to develop Android applications.
    1. Launch the Eclipse IDE
      $ ~/devel/eclipse/eclipse
    2. Select a workspace, I recommend to set the path to ~/devel/workspace and click "OK".
      Also recommended to selecting the "Use this as the default and do not ask again".
    3. Select Help->Install New Software
    4. Click "Add..."
    5. in the Name area enter "Android Development Tool (ADT) Plugin".
    6. In the Location area enter "https://dl-ssl.google.com/android/eclipse/".
    7. Click "OK"
    8. Back in the Available Software window, select the checkbox "Developer Tools".
    9. If available, select the checkbox "NDK Plugins" then click "Next".
    10. In the next window you'll see a list of tools to be installed, click "Next":
      - Android DDMS
      - Android Development Tools
      - Android Heirarchy Viewer
      - Android Native Development Tools
      - Android Traceview
      - Tracer for OpenGL ES
    11. Read then select "I accept the terms of the license agreement", click "Finish".
    12. If you're prompted with a message regarding unsigned content, just click "OK".
    13. After the plugin is downloaded you'll need to restart Eclipse. The plugin installer will prompt you about it select "Yes".

     

ADT Plugin Configuation

  1. Once Eclipse restarts you'll see a message "Location of the Android SDK has not been setup in the preferences", click "Close".
  2. In the "Welcome to Android Development" window, select "Use existing SDKs".
  3. Click "Browse" and navigate to ~/devel/android/android-sdk-linux where previously installed the Android SDK (see above), then click "OK".
  4. Click "Next"
  5. In the "Contribute Usage Statistics" window choose if you want to let the plugin send usage data to Google or NOT, then click "Finish".

 

Adding Platform and Packages

  1. With Eclipse running, select Window->Android SDK Manager
  2. Select the checbox of the following components
    • Tools->Android SDK Platform-Tools
    • Extras
    • At least one platform version, "Android 4.2 (API 17)" and "Android 2.2 (API 8)"
  3. Click "Install ## packages", where ## is the total number of packages shown based on your selection.
  4. Read the license of each component and select "Accept All" once ready, then click "Install".
  5. Once the Android SDK Manager Log shows all packages installed click "Close".
  6. Close the "Android SDK Manager" window.

 

Execute ADB

If all went well now you have all the tools required for interacting with your device or emulator. Try to execute the adb client:

$ cd ~/devel/android/android-sdk-linux/platform-tools

$ ./adb


In the case that you might experience the following error:


"./adb: No such file or directory"


is most likely that your system is using a 64bit Linux kernel. In order to fix this you'll need to install the following packages:

  • ia32-lib
  • ia32-lib-multiarch

 

The development environment is ready, you should be able to continue to start your first Android project.