Hot dawg. We got our Linux forum!
Setting up the SDK is easy on Linux. It's getting the supporting tools installed that is the PITA. Here's one way to get it done. This is geared to the Ubuntu user, but it's the same method for all distros.
*newbie tip* Linux gives all folders and files permissions. By default, a user has full control over his or her home directory. ~/ is the BASH shortcut for the current users home. We'll be using it a lot.
Running as root -- yes, there is a portion of this guide that has you run commands as root. This is a bad practice, but to make the guide simpler and more universal, it's necessary in this case. Just remember, when you're running as root, you can really screw things up. Everything. Really.
Step One -- 32-bit libraries and headers
If you're using a 32 bit version of Linux, be aware that building from the AOSP tree is no longer supported after version 2.2.2. Most modern processors will run (and benefit) from using a 64-bit version of Linux, so upgrading is something worth considering.
If you are using a 64-bit version of Linux, you'll need to install the 32-bit versions of some libraries, as they aren't installed by default. If you are using Ubuntu 10.10, open your terminal and install them like so:
If you're not using Ubuntu, no problem. Visit the Debian [lenny] package list and details page right here. We're using Debian's page because I'm old fashioned, and all my links are to Debian You can use the Ubuntu package list pages as well. In the list, find the package the Ubuntu users just installed. In this case, it's right here.
That's a list of what you need to install on your machine. Either find each in your Distro's install system, download pre-built binaries, or build them from source.
Do this each time you see a command for Ubuntu users to install software, and you can keep track of what's needed for your system.
Step Two -- Sun (Oracle) Java 6
The SDK almost works with open Java alternatives, but almost doesn't cut it. We need to install Oracle's closed source version of the Java Development Kit and Runtime Environment. Since it's closed source, it's not available by default in the Ubuntu package manager. These commands will add a repository to your apt source list that keeps the Linux version of Sun Java up to date and available, then install what's needed.
If you're using another Distro, you can get the binary from Oracle at their site right here.
Step Three -- download the SDK
Download the Android SDK for Linux right here. Open the archive, and extract the entire android-sdk-linux_86 folder into your home folder.
Now that you have it installed, you need to tell your shell where it is. Open your ~/.bashrc file and add it to your PATH. Here's a copy/paste method using nano:
use the enter key and scroll to the very end of the file, and enter these four lines, exactly as written, but using your user name:
Control+X will end nano, prompting you to save the file. Enter Y and save your .bashrc
Now you need to refresh your shell. Enter this at the prompt:
Step four -- download the rest of the SDK
The Android SDK is modular, so you have to download the components you want/need. We're going to download them all, because it's easier to explain and one day you might want to run the emulator. At the prompt:
On the left, choose Available packages.
Check the box that says Android Repository, then choose to install selected.
Choose Accept all and Install.
This take a few minutes, as it downloads everything you will ever need. If you want, you can choose to only install the tools and platform tools in your choice above.
Step five -- testing
On Ubuntu systems, adb has to run as root, or your device needs permission to communicate declared in the udev rules. You really should set up the udev rule for your phone and not run as root. In the meantime, you will need to restart adb as root each time your reboot or stop adb. Do it like so:
Everything above is being run as root. Don't forget the exit command.
Next, make sure USB debugging is enabled on your phone, and connect it to a full speed USB port, one that's not on a hub. Sometimes hubs and front ports work fine. Sometimes they don't. Use the right ones to test, and try others later once you know it all works. After it's connected go back to the terminal:
You should see a serial number. That means it worked. Now try:
You should see the same thing. This means your PATH was set-up right. And you're done. If you hit any snags, post away and we'll try to fix them.
Setting up the SDK is easy on Linux. It's getting the supporting tools installed that is the PITA. Here's one way to get it done. This is geared to the Ubuntu user, but it's the same method for all distros.
*newbie tip* Linux gives all folders and files permissions. By default, a user has full control over his or her home directory. ~/ is the BASH shortcut for the current users home. We'll be using it a lot.
Running as root -- yes, there is a portion of this guide that has you run commands as root. This is a bad practice, but to make the guide simpler and more universal, it's necessary in this case. Just remember, when you're running as root, you can really screw things up. Everything. Really.
Step One -- 32-bit libraries and headers
If you're using a 32 bit version of Linux, be aware that building from the AOSP tree is no longer supported after version 2.2.2. Most modern processors will run (and benefit) from using a 64-bit version of Linux, so upgrading is something worth considering.
If you are using a 64-bit version of Linux, you'll need to install the 32-bit versions of some libraries, as they aren't installed by default. If you are using Ubuntu 10.10, open your terminal and install them like so:
Code:
sudo apt-get install ia32-libs
If you're not using Ubuntu, no problem. Visit the Debian [lenny] package list and details page right here. We're using Debian's page because I'm old fashioned, and all my links are to Debian You can use the Ubuntu package list pages as well. In the list, find the package the Ubuntu users just installed. In this case, it's right here.
That's a list of what you need to install on your machine. Either find each in your Distro's install system, download pre-built binaries, or build them from source.
Do this each time you see a command for Ubuntu users to install software, and you can keep track of what's needed for your system.
Step Two -- Sun (Oracle) Java 6
The SDK almost works with open Java alternatives, but almost doesn't cut it. We need to install Oracle's closed source version of the Java Development Kit and Runtime Environment. Since it's closed source, it's not available by default in the Ubuntu package manager. These commands will add a repository to your apt source list that keeps the Linux version of Sun Java up to date and available, then install what's needed.
Code:
sudo add-apt-repository ppa:sun-java-community-team/sun-java6
sudo apt-get update
sudo apt-get install sun-java6-jdk
If you're using another Distro, you can get the binary from Oracle at their site right here.
Step Three -- download the SDK
Download the Android SDK for Linux right here. Open the archive, and extract the entire android-sdk-linux_86 folder into your home folder.
Now that you have it installed, you need to tell your shell where it is. Open your ~/.bashrc file and add it to your PATH. Here's a copy/paste method using nano:
Code:
nano -w ~/.bashrc
Code:
PATH=$PATH:/home/<user name>/android-sdk-linux_86/tools
export PATH
PATH=$PATH:/home/<user name>/android-sdk-linux_86/platform-tools
export PATH
Control+X will end nano, prompting you to save the file. Enter Y and save your .bashrc
Now you need to refresh your shell. Enter this at the prompt:
Code:
exec bash
Step four -- download the rest of the SDK
The Android SDK is modular, so you have to download the components you want/need. We're going to download them all, because it's easier to explain and one day you might want to run the emulator. At the prompt:
Code:
cd ~/android-sdk-linux_86/tools/
./android
Check the box that says Android Repository, then choose to install selected.
Choose Accept all and Install.
This take a few minutes, as it downloads everything you will ever need. If you want, you can choose to only install the tools and platform tools in your choice above.
Step five -- testing
On Ubuntu systems, adb has to run as root, or your device needs permission to communicate declared in the udev rules. You really should set up the udev rule for your phone and not run as root. In the meantime, you will need to restart adb as root each time your reboot or stop adb. Do it like so:
Code:
sudo su
<password>
cd /home/<username>/android-sdk-linux_86/platform-tools
./adb kill-server
./adb start-server
exit
Everything above is being run as root. Don't forget the exit command.
Next, make sure USB debugging is enabled on your phone, and connect it to a full speed USB port, one that's not on a hub. Sometimes hubs and front ports work fine. Sometimes they don't. Use the right ones to test, and try others later once you know it all works. After it's connected go back to the terminal:
Code:
cd ~/android-sdk-linux_86/platform-tools
./adb devices
You should see a serial number. That means it worked. Now try:
Code:
cd ~/
adb devices
You should see the same thing. This means your PATH was set-up right. And you're done. If you hit any snags, post away and we'll try to fix them.