Monday, December 23, 2013

How Configure an Android Development Environment on Linux

http://linuxaria.com/article/how-configure-an-android-development-environment-on-linux?lang=en

Original article (in spanish) posted on http://vidagnu.blogspot.it/
In this post I want to show the steps you must follow to have a Development Environment for Android in your Linux distro.
What do you need?
Let’s go !



As first thing install Java JDK 6, from the Oracle website it’s possible to download a .rpm.bin package or a .bin file, if you use an rpm based distribution such as Centos, Red hat, Fedora or Suse go for the first package, and if you have any problem check this article Install Sun/Oracle Java JDK/JRE 6u45 on Fedora 19/18, CentOS/RHEL 6.4/5.9
All the others users will have to use the .bin file, to verify that you have installed it you can use the command java -version from a terminal, you should see something similar at this:
java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b04)
Java HotSpot(TM) Server VM (build 20.6-b01, mixed mode)
Now declare the environment variable JAVA_HOME, the best way to do this it’s add these 2 lines in your ~/.bashrc file:
## export JAVA_HOME JDK ##
export JAVA_HOME="/usr/java/jdk1.6.0_45"
and include the “bin” folder that is inside the JAVA_HOME in the PATH environment variable adding this extra line to your ~/.bashrc file:
export PATH=$PATH:$JAVA_HOME/bin
Now proceed with the installation of Android SDK, to do it download the compressed file and unpack into /opt (or /usr/local if you prefer so), now you must create the ANDROID_HOME environment variable which should point to the folder /opt/android-sdk-linux, we must also add the directory “tools” that is within this newly created directory and contains the SDK executables in our PATH environment variable.
With this setup we have a basic framework to build applications for Android.
Now run the command “android” which will open the Android SDK Manager in which we will click on the button or link “New” to select all packages so they will be installed in our environment, this is the best time to take a coffee, as this process usually takes several minutes …
Now we need the IDE, we proceed with the unzip of ECLIPSE for Java Developers 3.7.2 in the /opt (or /usr/local) and add a new environment variable ECLIPSE that must contain /opt/eclipse.
To start Eclipse, run the command “eclipse”, the first time that you run the command it will say that you need to create your workspace which is basically a folder where you will store all the projects.
Now you just need to load the Android Plugin in Eclipse.
  1. Start Eclipse, then select Help > Install New Software.
  2. Click Add, in the top-right corner.
  3. In the Add Repository dialog that appears, enter “ADT Plugin” for the Name and the following URL for the Location:
    https://dl-ssl.google.com/android/eclipse/
  4. Click OK.If you have trouble acquiring the plugin, try using “http” in the Location URL, instead of “https” (https is preferred for security reasons).
  5. In the Available Software dialog, select the checkbox next to Developer Tools and clickNext.
  6. In the next window, you’ll see a list of the tools to be downloaded. Click Next.
  7. Read and accept the license agreements, then click Finish.If you get a security warning saying that the authenticity or validity of the software can’t be established, click OK.
  8. When the installation completes, restart Eclipse.
Upon completion you should see a new button that appear in the bar, which refer to Android, also when creating a new project you have the option of choose for Android as shown in the following screen:
android-eclipse-linux

No comments:

Post a Comment