Wednesday, May 29, 2013

[How to] Install Android SDK in Linux

How to install the Android SDK in Linux

¿De qué está hablando? Versión en español.

For this tutorial I am using Ubuntu 13.04 but the procedure is the same for all distros.

Note: I am not exactly sure about the permissions you need to give to the folders we are going to create. Feel free to change them. I gave all permissions so it will just work.

You will need Eclipse and Java installed. If you haven't got Eclipse all you have to do in Ubuntu is using this command (it will pull Java at the same time):

sudo apt-get install eclipse

Downloading the SDK for Android


First of all you need to get the SDK from the developer site of Android. Go this website and choose the last option: SDK Tools only.



Now you will need to extract those tools, and lets put them in the /opt directory.

sudo tar xzvf android-sdk_r22-linux.tgz -C /opt

We need to give permissions to this folder so Eclipse will be able to use the SDK.

sudo chmod 777 -R /opt/android-sdk-linux

Now we need to run the Android manager to download the packages we need.

cd /opt/android-sdk-linux/tools

./android



Be careful when you choose what you want to download because it takes a lot of memory. Normally you won't need anything extra if you want to run the latest Android version.

We can make a symbolic link because we are going to need this in the future.

sudo ln -s /opt/android-sdk-linux/tools/android /usr/bin/android

Using the manager


Now we want to make sure we can create a virtual machine running android.

Let's give all permissions to our configuration file. In order to let the SDK create a virtual Android device.

sudo chmod 777 -R  ~/.android

Launch the following command (make sure you created a symbolic link before):

./android avd


And create a new virtual device, if you don't have any, choose "New". You will see the different options that you downloaded with the SDK manager.



I recommend you to enable the GPU usage, the virtual device will run faster with that.
Launch the emulator and wait. It could take sometime to launch so don't panic. (Like I did)



Now we can install the plugin for Eclipse.

Installing the Eclipse plugin


Launch Eclipse and go to Help > Install New Software... > Add...

Choose Add... in the top right corner.

Then you will enter a name for the new software you are going to install, "Android" maybe. And in the URL section enter the following Location:

https://dl-ssl.google.com/android/eclipse/



Choose the "Developer Tools" and then click Next>.
Accept the "Terms and Conditions" and then choose Finish. Eclipse will restart but you won't be able to use the SDK just yet.

Configure the path to the SDK

Go to Windows > Preferences > Android and configure the "SDK Location" to:

/opt/android-sdk-linux



And choose Apply then click OK. Restart Eclipse and the Android SDK will be good to go.

Creating your first app


If you want to create a new application with Eclipse go to New > Other... and choose "Android Application Project".



It will create the application automatically.

If you want to test your app in the virtual device you will need to launch the device first and Eclipse will install and run the app in the device.

You can install and launch the app in a real device but you need to launch adb with root permissions. Just use the following commands.

sudo adb kill-server

sudo adb start-server

And if you want to check if your device is recognized use

adb devices



And that's it! Enjoy the SDK.

Did you like this post? Don't forget to add me to your circles in G+ or to follow me on Twitter: @RobertoXMed . If you can and if you want, don't forget to Donate so I can keep up the good work.

No comments:

Post a Comment