How To Install The Android SDK & Eclipse on Ubuntu


I have 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

  1. Android logoDownload the Android SDK.
  2. Download the SDK plugins you want.
  3. Download and install Eclipse.
  4. Move Eclipse and Android directories to a final installation folder [optional]
  5. Install the Android Development Tools for Eclipse
  6. Point Eclipse to the location of your Android SDK.
  7. 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.

Download the Android SDK for Ubuntu

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.

The Android SDK and AVD Manager in Ubuntu

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).

Eclipse Indigo in Ubuntu Natty

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/

Add the Google Android Repository to 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.’

Eclipse Android Preferences

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.

Create a new Android Project in Eclipse

After a few moments, your project will be ready to compile and test.

Android Project Java Source

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.

Eclipse ADT Run Configuration

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.

The Android 2.2 Virtual Device

Once the initialization is complete, our test application should run!

Virtualized Android Application

Source: GeekyAndroidGame

(Bu yazıyı aldığım kaynak, İzmir Ekonomi Üniversitesi son sınıf bitirme projesi için oluşturduğum bloğa ait)

Reklamlar

22 Eyl 2012 tarihinde Android içinde yayınlandı ve , , , olarak etiketlendi. Kalıcı bağlantıyı yer imlerinize ekleyin. 2 Yorum.

  1. thanks bro.. your tutorial help me

  2. 673927 918151 You really should take part in a contest for among the very best blogs on the internet. I will recommend this internet site! 213603

Bir Cevap Yazın

Aşağıya bilgilerinizi girin veya oturum açmak için bir simgeye tıklayın:

WordPress.com Logosu

WordPress.com hesabınızı kullanarak yorum yapıyorsunuz. Çıkış  Yap / Değiştir )

Twitter resmi

Twitter hesabınızı kullanarak yorum yapıyorsunuz. Çıkış  Yap / Değiştir )

Facebook fotoğrafı

Facebook hesabınızı kullanarak yorum yapıyorsunuz. Çıkış  Yap / Değiştir )

Google+ fotoğrafı

Google+ hesabınızı kullanarak yorum yapıyorsunuz. Çıkış  Yap / Değiştir )

Connecting to %s

%d blogcu bunu beğendi: