Copyright Notice

Thursday, October 18, 2012

Blog has moved to ----> mgw.dumatics.com

Few weeks back I updated to the latest Linux Mint offering "Maya" a.k.a Linux Mint 13. Now this is a LTS (Long Term Support) version and I wanted to be in a position to install everything right just so I can keep it for a longer duration and hence have been taking my time configuring stuff.

Last time when I had set up system for Android Development I remember messing up a lot and ending up installing too many things here and there and in the process did learn how to do it properly. I did not document that as a blog as it was too fragmented an experience at that time but this time round I did it properly and everything (well, okay, almost everything) was perfect.

There is lot of material on the web but again that is what led to a less than perfect install last time as it is all disjointed, making the sequence go wrong, using one way for one thing another way for second and ending us with a not so nice experience distracting you from what you want to do, start developing something on android platform or perhaps just get the adb set-up to flash your nexus phone.

So presented below is a guide that will help you prepare your Linux Mint 13 or equivalent distro for you to start android development.You will notice that these notes do not require downloading "android sdk" separately and that is to save time and effort, trust me.
So the high level steps are:

That's because Oracle Java 6 SDK is a pre-requisite for installing Android SDK but it's not available in Ubuntu or Linux Mint repository so it can't be installed using synaptic or apt-get.

Right then, I am assuming that all the files downloaded above are placed in "Downloads" directory. If not, please replace "Downloads" in all commands with whichever directory you have downloaded these file to.

1. Open terminal and type:

cd Downloads

2. Make the downloaded .bin Java 6 file executable and run using following commands:

chmod a+x jdk-6u37-linux-i586.bin

./jdk-6u37-linux-i586.bin

This will create a directory named "jdk1.6.0_37".

3. Untar the Java 7 SDK by typing following command in terminal:

tar -xvf jdk-7u7-linux-i586.tar.gz

This will create a directory named "jdk1.7.0_07".

4. Unzip the Java 6 api docs by typing following command in terminal:

unzip jdk-6u30-apidocs.zip -d jdk1.6.0_37/

This command will unzip the apidocs zip file and place the contents in "jdk1.6.0_37"

5. Unzip the Java 7 api docs by typing following command in terminal:

unzip jdk-7u6-apidocs.zip -d jdk1.7.0_07/

This command will unzip the apidocs zip file and place the contents in "jdk1.7.0_07"

6. Untar the Java 6 demos and samples using following command in terminal:

tar -xvf jdk-6u37-linux-i586-demos.tar.gz

This command will untar the demos and samples file and place the contents in "jdk1.6.0_37"

7. Untar the Java 7 demos and samples using following command in terminal:

tar -xvf jdk-7u9-linux-i586-demos.tar.gz

This will create a folder named jdk1.7.0_09. Copy the contents of this folder into jdk1.7.0_07.

8. Move the Java 6 to it's proper location using following command in the terminal:

sudo mv jdk1.6.0_37 /usr/lib/jvm

You will be asked to provide root password.

9. Now move the Java 7 to it's proper location using following command in the terminal:

sudo mv jdk1.7.0_07 /usr/lib/jvm

10. Make the script to update java update-java-0.5b executable and then execute it by using following commands in terminal.

chmod +x update-java-0.5b

sudo ./update-java-0.5b

You will be presented with following selection box:

11. Once you click on OK you will be presented with following screen:

Select the radio button and click on OK

12. Once Java 6 SDK is installed repeat step 10 and this time when you reach the selection window select Java 7 as shown below.

Select the radio button shown and click on OK

Now Oracle Java 6 and Oracle Java 7 will both be installed on your system. To check this you can use the tool "galternatives". This can be installed by typing following command on the terminal window:

sudo apt-get install galternatives

galternatives

This will open the "G Alternatives" window, scroll down to "Java" in left hand pane and click on it. You should see both versions installed and radio button for highest version selected as shown below:

Step 3: Install eclipse

1. Open Synaptic package manager and type eclipse, click on the check-box next to it and select "Mark for installation" then click on "Apply" as shown below.

2. Once Eclipse is installed, we need to find out whether the necessary SWT (Standard Widget Toolkit) libraries link are set correctly or not. This is to avoid Eclipse throwing a tantrum and not starting because it is unable to find the SWT library. As you can see in the screenshot below it's a pretty quick thing:

A) First type the following command to check if whether SWT directory exists or not:

ls ~/.swt/lib/linux/x86/

If you see the same message as shown in screenshot above "ls: cannot access /home//.swt/lib/linux/x86/: No such file or directory", then it means we need to create the SWT directory so continue to sub-step B.

If this command does not result in this message nor does it show a list of files (blue text in screenshot) then skip directly to sub-step C.

If it does show the list of files in blue in above screenshot, you don't need to do anything further and for you it's time to move to next step.

B) Type the following command in terminal to create the SWT directory:

mkdir -p ~/.swt/lib/linux/x86/

C) If the swt directory exist, but nothing is listed (no blue text), then run the following command in terminal:

ln -s /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86/

Finally as shown in screenshot, type the command in sub-step A once again and you should see the list shown in blue on the screenshot:

Time to move on to install ADT (Android Development Tools Plugin on eclipse.

Step 4: Install ADT Plug-in for Eclipse

OK we have so far installed Java, installed eclipse and now we are all set to install Android. To do so we will follow the screenshots below:

When you start eclipse, you will be shown a splash screen, ask you to set workspace which I leave default and finally this window will open. As shown, click on the Workbench in right hand side corner. This will lead to following window.

Here Click on Help > Install New Software. This will open following window.

Click on "Add" button in red rectangle above. Following pop-up window will appear.

In Name type "ADT Plugin" or whatever name you want to give.In Location type "https://dl-ssl.google.com/android/eclipse/"Then click OK. On following window it will first show pending but eventually it will look as below.

Here select the first option "Developer Tools" and click OK.

Click "NEXT".

Click "NEXT".

Let it run in foreground i.e. don't do anything and just wait.

Click "RESTART NOW". You will be presented with following window on restart.

Now leave the target location as is and leave everything as default and click "NEXT".

As shown above, selected the "ACCEPT ALL" radio button and click "INSTALL".

Now the android SDK is installed on the system along with other things. Close all the open windows just to clear any screen clutter. Now open the terminal and type following commands:

cd android-sdks/tools

./android

It will open the following window:

1. Select as shown above and optionally you can also select checkbox against Documentation and Samples. Once done click on "INSTALL x Packages". 2. On the next window, for which I did not take a screenshot but which is same as the one before previous screenshot of terminal, select radio button "ACCEPT ALL" and click on "INSTALL". 3. Now once you are back to this window select "Google APIs" and click on "Install 1 package".4. On the package lis, click on "ACCEPT" radio button and click on "INSTALL".

Android Development Tools and SDK is now installed. We just need to configure few things.

Step 5: Final Configurationsadb Environmental Variables

1. Go to home folder
2. Press Ctrl+H

3. Locate the .bashrc file, if it does not exist, create one (In home folder, right click and select "Create New Document > Empty Document").

4. Open the file in gedit and add the following at the end, if you created the file yourself just add this line and save.

export PATH=${PATH}:/tools:/platform-tools

Set the PATH environment
1. Go to home folder
2. Press Ctrl+H
3. Locate the .profile file
4. Open the file in gedit and add the following at the end.

# set PATH so it includes user's Android SDK if it exists
if [ -d "$HOME/android-sdks" ] ; then
PATH="$HOME/android-sdks:$HOME/android-sdks/tools:$PATH"
fi

Set-up udev

This step is only required if you want to use your android device for development purpose or if you want to flash a custom ROM.

1. Open the terminal and type following:

gksudo nautilus /etc/udev/rules.d

2. Create new document like we did above- Right click on empty space and select "Create New Document" and then "Empty Document.

3. Name this document as "51-android.rules"

4. Open the document with Gedit and add following lines - assuming you are using "Nexus S" like me, if not see if your phone details are available on this link: http://wiki.cyanogenmod.com/wiki/Udev and if not follow the guideline under the heading "Manually create udev rules" on that link.

5. Now make this 51-android.rules file executable by typing following command in the terminal window: