I’ve been experimenting with mobile app development for a while now, and I recently wanted to install the Android SDK (r11) and Eclipse 3.7 (Indigo) on my laptop, which runs Ubuntu 11.04 (Natty Narwhal). Eclipse provides a great IDE for writing your code, and the Android SDK provides all of the device files and Android-specific goodies you need to implement your applications on Android devices. I followed the guides on the Android and Eclipse website, and the process was pretty straightforward. This tutorial assumes you have a Java Virtual Machine already set up on your system. I use Sun’s JVM but others should work just as well.
Summary
- Download the Android SDK.
- Download the SDK plugins you want.
- Download and install Eclipse.
- Move Eclipse and Android directories to a final installation folder [optional]
- Install the Android Development Tools for Eclipse
- Point Eclipse to the location of your Android SDK.
- Start writing Android applications!
1. Download the Android SDK.
First, head over to the Android SDK Download page and download the latest SDK version that fits your environment (x86 or x64). At the time of this writing, the most recent stable SDK is r11.
It’s a pretty quick download. Once you have the archive, extract it into a folder. You can work in your windowing manager but I prefer the command line. I extracted with the following command:
$ tar xzvf android-sdk_r11-linux_x86.tgz
Tar is the GNU archiving tool. The xzvf flags mean ‘extract, unzip, verbose, (from) file.’ The untarring should result in the creation of an ‘android-sdk-linux_x86′ folder in the same directory as the tar file. Open the folder and go into the ‘tools’ directory, where you can execute the ‘android’ program.
$ cd android-sdk-linux_x86/tools
android-sdk-linux_x86/tools$ ./android
This will open the Android SDK and AVD manager.
2. Download the SDK plugins you want.
At this point, you should select the SDK elements and APIs you would like to have available for developing. If you want to develop cross-platform Android apps, you should probably download everything. If you only want to target a specific device, download the APIs and Android versions that apply to that device. There are a number of options to choose from. Make your selection from the available packages and click “Install Selected.” In my case, I downloaded a bunch of different platform tools and APIs, so the download took a while. While it’s downloading, let’s install Eclipse.
3. Download and install Eclipse.
If you like to stick with the Ubuntu repositories, you can install Eclipse using apt-get or Synaptic. However, at the time of this writing, Eclipse Indigo was just released and it isn’t available in any of the repositories so I downloaded it from the Eclipse website (over bittorrent, for speed and to help their bandwidth). Either way, the folks at Android recommend the Eclipse Classic installation.
To install from the Ubuntu repositories:
$ sudo apt-get install eclipse
To install from the Eclipse website, go to their Downloads page and get the latest version of Eclipse Classic. In my case, I downloaded “eclipse-SDK-3.7-linux-gtk.tar.gz.” To extract the files in the archive, I typed,
$ tar xzvf eclipse-SDK-3.7-linux-gtk.tar.gz
This should extract an ‘eclipse’ folder that contains a functional Eclipse installation. Enter the folder and run the main eclipse application to make sure it works.
$ cd eclipse
$ ~/eclipse$ ./eclipse
The Eclipse splash screen should pop up and ask you where you want to store your workspace files. I went with the default (~/workspace).
4. Move Eclipse and Android directories to a final installation folder [optional]
I verified that Eclipse was working, and noticed that my Android SDK targets had finished downloading, so I closed both applications and moved the Android and Eclipse folders to my /opt/ directory, because that’s how I like to organize my system. You can skip this step or place the files in a different location if you like.
I issued the following commands to move the folders and change their permissions. Substitute ‘USER’ for your username:
$ sudo mv eclipse/ /opt/
$ sudo mv android-sdk-linux_x86/ /opt/
$ sudo chown -R USER:USER /opt/android-sdk-linux_x86/
5. Install the Android Development Tools for Eclipse
Now that Eclipse and the Android SDK are installed, we need to add the Android Development Tools (ADT) to our Eclipse installation. Up to date instructions can be found on the ADT Website. Start Eclipse and go to Help > Install New Software. Then click the ‘Add’ button at the top of the window. An “Add Repository” window will pop up. Pick a name, (I chose ‘Google Android’) enter the following URL in the ‘Location’ box and click OK:
https://dl-ssl.google.com/android/eclipse/
Now you can select select the location you added from the ‘Work With:’ dropdown. Check the ‘Developer Tools’ box and click ‘Next’ to proceed with the installation. Once you’ve agreed to the Terms and Conditions, click Finish. When you restart Eclipse, the installation will be complete.
6. Point Eclipse to the location of your Android SDK.
Once the ADT is installed, you need to enter the location of your Android SDK into Eclipse. Click the Window menu and select ‘Preferences.’ Then click ‘Android’ and enter the location of your Android SDK folder. In my case, it was ‘/opt/android-sdk-linux_x86.’
After you enter your SDK folder location and click ‘Apply,’ the list should be populated with the SDK targets you installed. After you click ‘OK,’ you’re ready to start writing Android Applications!
7. Start writing Android applications!
To create your first Android project, go to File > New Project and select ‘Android.’ Click Android Project, and enter a Project Name, an Application Name and a Package Name and select the Android version you would like to target and click ‘Next,’ then ‘Finish. I picked “Test1, Test1 and com.android.test1″ respectively, and I targeted Android 2.2.
After a few moments, your project will be ready to compile and test.
Before you run your project, you will need to create a new Run Configuration. Click Run>Run Configuration and double-click ‘Android Application.’ Specify a name for your configuration, click ‘Browse’ and select your project before clicking OK.
Click ‘Run’ and wait for the virtual device initialization to complete. The first time you run a program on a newly-created virtual device, the initialization will take a while. After the first run, the virtual device should start up more quickly.
Once the initialization is complete, our test application should run!
Source : dml4.com