There are a few things that need to be done to get started with Android development on Linux including installing Oracle Java, the Android SDK, and your favorite IDE. The following steps will get you up and running with Android development on Sputnik 2 (and most other Linux distros).
1. Install Oracle Java 6
Oracle Java 6 is the recommended JDK for Android development. Ubuntu ships with OpenJDK installed, rather than the official Oracle implementation. OpenJDK is also incompatible with IntelliJ IDEA (my preferred Android IDE). I followed the steps outlined on AskUbuntu to install and configure Oracle JDK 6.Once the installation is complete, run the following command in a terminal to verify you are running the correct version of Java.
$ java -version
java version "1.6.0_43"
Java(TM) SE Runtime Environment (build 1.6.0_43-b01)
Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01, mixed mode)
2. Install Linux Android SDK
The Android SDK for Linux is available from http://developer.android.com/sdk. Recently, Google has bundled the Android SDK with Eclipse and the ADT plugin. To download just the SDK proper, click on "Use An Existing IDE" further down the page.
Once the download is complete, you can unpack and install the SDK with the following commands.
$ cd ~/Downloads
$ tar xvfz android-sdk_r21.1-linux.tgz
$ sudo mkdir /opt/local
$ sudo chmod +rx /opt/local
$ sudo mv android-sdk-linux /opt/local/android-sdk
$ chmod +rx -R /opt/local/android-sdk
$ tar xvfz android-sdk_r21.1-linux.tgz
$ sudo mkdir /opt/local
$ sudo chmod +rx /opt/local
$ sudo mv android-sdk-linux /opt/local/android-sdk
$ chmod +rx -R /opt/local/android-sdk
Now you can start the Android SDK Manger tool.
$ /opt/local/android-sdk/tools/android
At a minimum, I recommend installing Platform Tools, Android Support Library, and the latest version of the platform, currently Android 4.2.2 (API 17).
After installing these components, add the following environment variables to your favorite shell startup script (.bashrc, .bash_profile, .profile). Also add the Android tools to the executable path.
# Set Java Home and Android Home environment variables.
export JAVA_HOME="/usr/lib/jvm/java-6-oracle"
export ANDROID_HOME="/opt/local/android-sdk"
# Add Android tools to executable path.
export PATH="$PATH:$ANDROID_HOME/tools"
export PATH="$PATH:$ANDROID_HOME/platform-tools"
Finally, some of the Android tools (like adb) require the 32-bit compatibility libraries on Linux. Run the following command to install these packages.
$ sudo apt-get install ia32-libs
$ /opt/local/android-sdk/tools/android
At a minimum, I recommend installing Platform Tools, Android Support Library, and the latest version of the platform, currently Android 4.2.2 (API 17).
After installing these components, add the following environment variables to your favorite shell startup script (.bashrc, .bash_profile, .profile). Also add the Android tools to the executable path.
# Set Java Home and Android Home environment variables.
export JAVA_HOME="/usr/lib/jvm/java-6-oracle"
export ANDROID_HOME="/opt/local/android-sdk"
# Add Android tools to executable path.
export PATH="$PATH:$ANDROID_HOME/tools"
export PATH="$PATH:$ANDROID_HOME/platform-tools"
Finally, some of the Android tools (like adb) require the 32-bit compatibility libraries on Linux. Run the following command to install these packages.
$ sudo apt-get install ia32-libs
3. Install IntelliJ IDEA
Download the latest version of IntelliJ IDEA Community Edition from http://www.jetbrains.com/idea/download. This free and open source edition includes full Android development support.
Unpack and launch the app using the script idea.sh in the /bin subdirectory.
$ cd ~/Downloads
$ tar xvfz ideaIC-12.0.4.tar.gz
$ mkdir ~/Applications
$ mv idea-IC-123.169 ~/Applications
$ ~/Applications/idea-IC-123.169/bin/idea.sh
You can also add this script to the executable path or add a symlink to /usr/local/bin for convenience.
$ cd /usr/local/bin
$ sudo ln -s ~/Applications/idea-IC-123.169/bin/idea.sh idea
When you launch IntelliJ IDEA for the first time you will need to configure the Java and Android SDKs. First we will configure the JDK:
Unpack and launch the app using the script idea.sh in the /bin subdirectory.
$ cd ~/Downloads
$ tar xvfz ideaIC-12.0.4.tar.gz
$ mkdir ~/Applications
$ mv idea-IC-123.169 ~/Applications
$ ~/Applications/idea-IC-123.169/bin/idea.sh
You can also add this script to the executable path or add a symlink to /usr/local/bin for convenience.
$ cd /usr/local/bin
$ sudo ln -s ~/Applications/idea-IC-123.169/bin/idea.sh idea
When you launch IntelliJ IDEA for the first time you will need to configure the Java and Android SDKs. First we will configure the JDK:
- Click Configure > Project Defaults > Project Structure
- Under Platform Settings, click SDKs
- Click the plus (+) sign to add a new SDK
- Choose JDK, then select the folder for java-6-oracle and click OK
- Type in the name "JDK 1.6" then click OK
Next we will configure the Android SDK:
- Click Configure > Project Defaults > Project Structure
- Under Platform Settings, click SDKs
- Click the plus (+) sign to add a new SDK
- Choose Android SDK, then select /opt/local/android-sdk and click OK
- Choose JDK 1.6 and Android 4.2.2 then click OK
- Click OK to finish
4. Build and Run Hello World!
Now that Oracle JDK 1.6, Android SDK 4.2.2, and IntelliJ IDEA are installed and configured we are ready to build and run our first Android app.
- Launch IntelliJ IDEA
- Choose "Create New Project"
- Enter project name "Hello Spacedroid"
- Enter project location /home/[username]/IdeaProjects/hello_spacedroid
- Click "Next" button
- Change Target Device setting to USB device and click "Finish" button
- Attach a device via USB
- Run the configuration for "hello_spacedroid"
Android development on the Sputnik 2 is now ready for takeoff.
This article is a creative one and the concept is good to enhance our knowledge. Waiting for more updates.
ReplyDeleteAndroid Development Course Online
Online Courses for Content Writing
Nice blog, very informative content.Thanks for sharing, waiting for the next update…
ReplyDeleteC C++ Training in Coimbatore