- Ubuntu Documentation
- Preparation and Installation
- Downloading the SDK Starter Package
- Setting up Java
- Downloading the SDK platform tools
- Post-Installation Configuration
- Modifying the PATH Environment Variable
- Preparing Hardware
- How to install Android SDK on Ubuntu?
- 8 Answers 8
- How to set ANDROID_HOME path in ubuntu?
- 20 Answers 20
Ubuntu Documentation
This is a general overview of what the Android SDK is, what it does, and how it can benefit you. This guide also contains instructions on how to set up the Android SDK on Ubuntu 10.04 onwards.
The Android Software Development Kit (AKA SDK) is a software suite for the Android mobile operating system that allows you to write applications for Android in the Java programming language. Most people who use the Android SDK either develop applications for the Android operating system OR they use it for other purposes, such as obtaining elevated privileges on an Android device with the help of third-party software or use it for diagnostic purposes in case of malfunctioning.
The vast majority of Android users probably won’t have to make use of the Android SDK, however, it is useful if you wish to learn more about the Android operating system and even then it’s still a handy tool to have in case something goes wrong.
This tutorial covers Ubuntu 10.04 Lucid Lynx onwards. For anything prior to Lucid, you will have to find it yourself.
Preparation and Installation
Before we set up the SDK, we have some preparation to do. Due to some major changes in the Android SDK made in the last couple of months, setting up the Android SDK is not as easy as it was two years ago, when Android was starting to take off. Setting up the SDK itself is relatively easy once the preparation has been done.
Downloading the SDK Starter Package
First things first, we have to obtain the starter package. The SDK starter package can be obtained at http://developer.android.com/sdk/index.html.
Download the one for Linux (.tgz file) and once it’s finished downloading, extract it to somewhere safe and easy to reach. For example, the home folder. To do so, open up a terminal, navigate to the directory where the SDK was downloaded and enter the following command:
$ tar -xvzf android-sdk_rXX-linux.tgz && mv android-sdk-linux
As of 12 May 2012, the Android SDK is currently up to r18, however that is set to change in the near future, and as such, replace XX with the version of your SDK.
Setting up Java
Prior to SDK r08, everything you’ll need to develop applications was included on a 100-200MB .tgz archive. However, with the release of SDK r08, the tools necessary for creating and building applications was removed and can be obtained by using the Android SDK and AVD Manager which is located in the / /tools folder.
However, you should not execute the Android SDK and AVD manager just yet, as you’ll most likely get a Parse: XML error notice. The reason for this is that after SDK r08, it’s now required to have Java installed before you set up the SDK. To do this, we’ll download the OpenJDK and the Icedtea browser plugin. In a terminal window, enter the following command:
$ sudo apt-get install openjdk-6-jre openjdk-6-jdk icedtea6-plugin
This will download and install the OpenJDK implementation of Java, which will be sufficient enough for us to download the SDK platform tools.
Downloading the SDK platform tools
This is pretty much the actual «installation» of the SDK’s platform tools. One key reason why this step is important is that it contains an important protocol called the Android Debug Bridge (ADB).
ADB comes bundled with the SDK platform tools. It is a command-line tool used to communicate with and control the device over a USB link from a computer. The tool comes bundled with the Android SDK and is commonly used for diagnosing problems with the device. Once you have ADB installed, you can use ADB to copy files to and from the device’s internal memory, install apps, run commands, see logs and more. This makes it an invaluable tool if your device is running into some trouble that might warrant a new device.
Now, in order to obtain the SDK platform tools, we’ll need to initialize the Android SDK and AVD Manager that I mentioned earlier. To do so, enter the following commands in a terminal. The first command will direct you to where the Android SDK and AVD Manager is located, and the second will execute said program.
/android-sdk-linux/tools
Once you do that, a new window will pop up, which is the actual Android SDK and AVD Manager. Click on «Available Packages» and you will be presented with two boxes. One is the Android Repository and the other is the Third-party Add-ons. Click on «Android Repository» then click on Install Selected. A confirmation window will pop up. Click on «Accept All» and then click on the Install button to install the SDK platform tools. It’s quite a bit to download so make sure you have at least 512MB to 2GB of hard drive space available. Once the download has finished, you’ll get a notice saying that the ADB daemon needs to be restarted. Click on «Yes» and everything will finish downloading.
Post-Installation Configuration
Now once the download has finished, or while you’re waiting for the download to finish, we have to configure Ubuntu a little to meet our needs. First, we have to set up the PATH variable to include ADB and other SDK tools, and we have to make sure our hardware will be detected once we initialize ADB.
Modifying the PATH Environment Variable
In the days before Android 2.2, a good number of people used to place their various projects and applications in the directories where the necessary tools they used existed. This was in itself a very flawed method because it cluttered up the directories, and while cleaning up the SDK, one might accidentally delete a crucial file, which will cause the SDK to fail and having to completely reinstall everything.
Modifying the PATH Environment Variable will help out immensely when it comes down to making use of SDK tools like ADB. Doing this will also allow you to execute certain protocols like ADB from ANY location. So if you’re operating from the Desktop, you don’t have to redirect to the SDK’s platform-tools folder to make use of ADB if you need to make use of it.
Enough chatter, let’s get busy. To modify the PATH variable of your system, you need to edit your .bashrc file. To do so, in a terminal, execute the following command:
You will now have the Nano text editor enabled on the terminal. Now, at the very top of the file, enter the following:
/android-sdk-linux/tools
/android-sdk-linux/platform-tools
Once you’re finished, press CTRL + X, Y, and then hit Enter to save your changes and exit the Nano text editor.
Preparing Hardware
Now that we have our PATH variable set up, we need to make sure our hardware will be detected once we initialize ADB. However, up until Natty, udev in Ubuntu wouldn’t allow ADB access to the Android phone via USB. This was fixed in udev version 165-0ubuntu1 — if you are running an earlier version ( apt-cache policy udev will tell you whether you are), you’ll need need to create a new udev rule file as root.
In a terminal, execute the following command that will create the rule file. This will utilize the graphical sudo command, so that we can still have control over the file if we’re not a root user.
$ gksudo gedit /etc/udev/rules.d/51-android.rules
Copy and paste the following udev rules in the text editor that opened up which contains the new rule file we created. The rules included should work with most if not all Android devices across multiple manufacturers, such as HTC, Motorola, LGE, and so forth.
SUBSYSTEM==»usb», ATTRS SUBSYSTEM==»usb», ATTRS SUBSYSTEM==»usb», ATTRS SUBSYSTEM==»usb», ATTRS SUBSYSTEM==»usb», ATTRS SUBSYSTEM==»usb», ATTRS SUBSYSTEM==»usb», ATTRS SUBSYSTEM==»usb», ATTRS SUBSYSTEM==»usb», ATTRS SUBSYSTEM==»usb», ATTRS Once you’ve copied and pasted the udev rules in the text editor which contains your newly created rule file, save your changes and quit. Now that you’ve set your udev rules you have to reboot so that ADB will be in your path. To test your changes, open up a terminal and execute the following: $ adb devices Note: You may need to enable USB debugging mode on your phone first in order for it to be recognised. This will give you two messages: 1) It will tell you it’s initializing the ADB daemon. 2) It should show you a list of connected devices. If all went well you should see your device’s serial number under the list of connected devices. If you see a message like: List of connected devices . No permissions This means your hardware was detected, however you made a mistake in configuring Ubuntu or the udev rule for your phone’s manufacturer was not listed. AndroidSDK (последним исправлял пользователь uusijani 2012-07-28 15:47:15) The material on this wiki is available under a free license, see Copyright / License for details Источник For my Ubuntu machine, I downloaded the latest version of Android SDK from this page. After extracting the downloaded .tgz file, I was trying to search for installation instructions and found: To get started on Linux: Unpack the .zip file you’ve downloaded. The SDK files are download separately to a user-specified directory. Make a note of the name and location of the SDK directory on your system—you will need to refer to the SDK directory later when using the SDK tools from the command line. What exactly are we supposed to do? Option 1: The location of Android SDK on Linux can be any of the following: Option 2: Extract downloaded .zip file. The extracted folder name will read somewhat like android-studio To keep navigation easy, move this folder to Home directory. After moving, copy the moved folder by right clicking it. This action will place folder’s location to clipboard. Use Ctrl Alt T to open a terminal Go to this folder’s directory using cd /home/(USER NAME)/android-studio/bin/ Type this command to make studio.sh executable: chmod +x studio.sh A pop up will be shown asking for installation settings. In my particular case, it is a fresh install so I’ll go with selecting I do not have a previous version of Studio or I do not want to import my settings. If you choose to import settings anyway, you may need to close any old project which is opened in order to get a working Android SDK. From now onwards, setup wizard will guide you. Android Studio can work with both Open JDK and Oracle’s JDK (recommended). Incase, Open JDK is installed the wizard will recommend installing Oracle Java JDK because some UI and performance issues are reported while using OpenJDK. The downside with Oracle’s JDK is that it won’t update with the rest of your system like OpenJDK will. The wizard may also prompt about the input problems with IDEA . Select install type Verify installation settings An emulator can also be configured as needed. The wizard will start downloading the necessary SDK tools The wizard may also show an error about Linux 32 Bit Libraries, which can be solved by using the below command: sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 After this, all the required components will be downloaded and installed automatically. After everything is upto the mark, just click finish To make a Desktop icon, go to ‘Configure’ and then click ‘Create Desktop Entry’ Источник How to set ANDROID_HOME path in ubuntu? Please provide the steps. In the console just type these : If you want to make it permanent just add those lines in the /.bashrc in your terminal. The folder you are in has no importance I would like to share an answer that also demonstrates approach using the Android SDK provided by the Ubuntu repository: Install Android SDK Export environmental variables Assuming you have the sdk extracted at Add the above lines to the file /.bashrc (located at home/username/.bashrc ) to make it permanent for the current user. Run source /.bashrc to apply the changes or restart your terminal. Run the above lines on a terminal window to make it available for the session. To test if you have set it up correctly, Run the below commands on a terminal window echo $ANDROID_HOME which android Run android on a terminal window, If it opens up Android SDK Manager, you are good to go. /.profile (or .bashrc) if you don’t want to logout.. then try running ‘sdkmanager —licenses’. Then try compiling. better way is to reuse ANDROID_HOME variable in path variable. if your ANDROID_HOME variable changes you just have to make change at one place. Initially go to your home and press Ctrl + H it will show you hidden files now look for .bashrc file, open it with any text editor then place below lines at the end of file. Please change /home/varun/Android/Sdk path to your SDK path. Do the same for tools and platform-tools. After this save .bashrc file and close it. Now you are ready to use ADB commands on terminal. Add the following to your /.bashrc file. Log-out and log-in. I have my sdk in $HOME/Documents/Android/sdk you have to replace it with where you keep your sdk folder /.bashrc can substitute for logging out then logging in. first open the .bashrc file by gedit # Added ANDROID_HOME variable. export ANDROID_HOME=$HOME/Android/Sdk export PATH=$PATH:$ANDROID_HOME/tools export PATH=$PATH:$ANDROID_HOME/platform-tools save the file and reopen the terminal it will show the path like /home/pathTo/Android/Sdk Applies to Ubuntu and Linux Mint Restart the terminal and doing: echo $ HOME or $ PATH, you can know these variables. This is what work for me, Assuming you have the sdk extracted at Add the above lines to the file /.bashrc (located at home/username/.bashrc ) to make it permanent for the current user. Run source /.bashrc to apply the changes or restart your terminal. (or) Run the above lines on a terminal window to make it available for the session. To test if you have set it up correctly, Run the below commands on a terminal window You can run this too Run android on a terminal, If it opens up Android SDK Manager, you are good to go. Источник
You can contribute to this wiki, see Wiki Guide for detailsHow to install Android SDK on Ubuntu?
8 Answers 8
How to set ANDROID_HOME path in ubuntu?
20 Answers 20