Setting up Android SDK/ADT Bundle on Fedora

This guide shows a step-by-step method on how to quickly and easily get started with Android Application development by installing and configuring the android development toolkit (ADT) bundle on Fedora 20.

I have tested this method on Fedora 20. It may be similar for the following Linux distros as well

  • Fedora 16 and above
  • CentOS 6 and above
  • Red Hat (RHEL) 6 and above

Download the ADT bundle

Method 1

Download the ADT bundle according to your architecture from
http://developer.android.com/sdk/index.html.

Method 2

Download using wget by typing the following command

## 32-bit ##
wget -c http://dl.google.com/android/adt/22.6.2/adt-bundle-linux-x86-20140321.zip 

## 64-bit ##
wget -c http://dl.google.com/android/adt/22.6.2/adt-bundle-linux-x86_64-20140321.zip

Setting up Oracle JDK

Most of the android stuffs do not work properly with Openjdk Java and it is advisable to use the Oracle/Sun JDK.
Here is a guide to install Oracle/Sun Java JDK

Setting up ADT bundle

You can extract the downloaded file anywhere you want. I have kept my ADT bundle at “/Android Dev”. You can extract there by typing the following in the terminal.

NOTE : Change “defoliate” in the last statement with your username.

## 32-bit ## 
sudo mkdir /"Android Dev" 
sudo cp adt-bundle-linux-x86-20140321.zip /"Android Dev" 
cd /"Android Dev" 
sudo unzip adt-bundle-linux-x86-20140321.zip 
sudo rm adt-bundle-linux-x86-20140321.zip
sudo chown -R defoliate:users /"Android Dev"

## 64-bit ## 
sudo mkdir /"Android Dev" 
sudo cp adt-bundle-linux-x86_64-20140321.zip /"Android Dev" 
cd /"Android Dev" 
sudo unzip adt-bundle-linux-x86_64-20140321.zip 
sudo rm adt-bundle-linux-x86_64-20140321.zip
sudo chown -R defoliate:users /"Android Dev"

If you have 64-bit systems and you installed the 64-bit version of the ADT Bundle, you will need to install some 32-bit packages as well, because Android SDK is 32-bit .
For installing these 32-bit packages, enter the following in terminal

## Only for 64-bit systems ##
sudo yum install glibc.i686 glibc-devel.i686 libstdc++.i686 zlib-devel.i686 ncurses-devel.i686 libX11-devel.i686 libXrender.i686 libXrandr.i686

Launching ADT Eclipse Bundle from Terminal

Make a symbolic link to adt eclipse so as to distinguish it from normal eclipse. Also we can make a symbolic link to the sdk manager for easy use.

## ADT Eclipse ##
sudo ln -s /"Android Dev"/adt-bundle-linux*/eclipse/eclipse /"Android Dev"/adt-bundle-linux*/eclipse/adt

## SDK Manager ##
sudo ln -s /"Android Dev"/adt-bundle-linux*/sdk/tools/android /"Android Dev"/adt-bundle-linux*/sdk/tools/sdk

Now we need to add Android SDK and ADT Eclipse into PATH environment variable. For this we need to edit the ~/.bashrc file. For editing that file, enter the following into the terminal.

sudo gedit ~/.bashrc

Add the following lines into that file

PATH=$PATH:/"Android Dev"/sdk:/"Android Dev"/sdk/tools:/"Android Dev"/sdk/platform-tools:/"Android Dev"/eclipse
export PATH

Now load the new settings using the following command

source ~/.bashrc

For running the sdk manager or the adt eclipse you can type the following into terminal now.

## SDK-Manager ##
sdk

## ADT Eclipse ##
adt

Install Oracle Java JDK Version 8u11 on Fedora

I have tested this method on Fedora 20. It may be similar for the following Linux versions as well

  • Fedora 16 and above
  • CentOS 6 and above
  • Red Hat (RHEL) 6 and above

By default, Openjdk java is provided with the OS. But sometimes, people want to use the Oracle/Sun version.

Difference between Openjdk java and Oracle java

Technical differences are a consequence of the goal of each one (OpenJDK is meant to be the reference implementation, open to the community, while Oracle is meant to be a commercial one)

They both have “almost” the same code of the classes in the Java API; but the code for the virtual machine itself is actually different, and when it comes to libraries, OpenJDK tends to use open libraries while Oracle tends to use closed ones; for instance, the font library.

It is generally preferred to use Oracle Java if you are wishing to develop android apps as some of the features may not work with openjdk java. For general programming openjdk is preferred.

Download the latest rpm file

Method 1

Download Sun/Oracle Java from here
http://www.oracle.com/technetwork/java/javase/downloads/index.html

Select rpm package as follows

  • JDK 32 bit jdk-8u11-linux-i586.rpm
  • JDK 64 bit jdk-8u11-linux-x64.rpm

Method 2

Just type the following in the terminal

## JDK 32-bit ##
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u11-b12/jdk-8u11-linux-i586.rpm"


## JDK 64-bit ##
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u11-b12/jdk-8u11-linux-x64.rpm"

Login as root

Type the following in the terminal

su -

Install Java JDK or JRE package

Double click install the rpm package or just type the following to install the downloaded package.

## JDK 32-bit ##
rpm -Uvh /path/to/binary/jdk-8u11-linux-i586.rpm

## JDK 64-bit ##
rpm -Uvh /path/to/binary/jdk-8u11-linux-x64.rpm

Install browser plugins and javac

Method 1 – Use Java JDK latest version (/usr/java/latest)

Type the following into the terminal

## java ##
alternatives --install /usr/bin/java java /usr/java/latest/jre/bin/java 200000

## javaws ##
alternatives --install /usr/bin/javaws javaws /usr/java/latest/jre/bin/javaws 200000

## Java Browser (Mozilla) Plugin 32-bit ##
alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/latest/jre/lib/i386/libnpjp2.so 200000

## Java Browser (Mozilla) Plugin 64-bit ##
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/latest/jre/lib/amd64/libnpjp2.so 200000

## javac ##
alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 200000

## jar ##
alternatives --install /usr/bin/jar jar /usr/java/latest/bin/jar 200000

Method 2 – Use Java JDK absolute version (/usr/java/jdk1.8.0_11)

Type the following in the terminal

## java ##
alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_11/jre/bin/java 200000

## javaws ##
alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.8.0_11/jre/bin/javaws 200000

## Java Browser (Mozilla) Plugin 32-bit ##
alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/jdk1.8.0_11/jre/lib/i386/libnpjp2.so 200000

## Java Browser (Mozilla) Plugin 64-bit ##
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/jdk1.8.0_11/jre/lib/amd64/libnpjp2.so 200000

## javac ##
alternatives --install /usr/bin/javac javac /usr/java/jdk1.8.0_11/bin/javac 200000

## jar ##
alternatives --install /usr/bin/jar jar /usr/java/jdk1.8.0_11/bin/jar 200000

Set environmental variable

Setup JAVA_HOME and PATH environment variable, i.e, adding JAVA_HOME environment variable to /etc/profile file or $HOME/.bash_profile file and setting PATH.

Method 1 – Java JDK latest version (/usr/java/latest)

export JAVA_HOME="/usr/java/latest"
export PATH=$PATH:/usr/java/latest/bin:/usr/java/latest/jre/bin

Method 2 – Java JDK absolute version (/usr/java/jdk1.8.0_05)

export JAVA_HOME="/usr/java/jdk1.8.0_11"
export PATH=$PATH:/usr/java/jdk1.8.0_11/bin:/usr/java/jdk1.8.0_11/jre/bin

Checking whether installation is successful

Check java, javaws and javac

checking java

Check mozilla firefox java plugin

Test the plugin out at: www.java.com/en/download/help/testvm.xml
A browser restart is not always required.

You can alse check libjavaplugin.so by restarting Mozilla Firefox and writing about:plugins on address bar.

firefox plugin
I hope this works out for everyone. Comment for any queries and I will reply asap.

Installing Fedy (Fedora Utils)

I’ve discovered a really nice tool than can be very useful in a daily basis. I’m talking about Fedy, by satya164, an open source GitHub project.

Fedy (earlier knows as “Fedora Utils”) is the “Graphical Tweak” of Fedora. It simplifies many of the post install tasks. It’s basically a collection of scripts and customizable plugins wrapped around a nice GUI which  help you install fonts, codecs, flash, java, etc. It also cleans up your system, fixes some common issues, tweaks your desktop, etc.

Literally, as its creator said: “Fedora Utils lets you install codecs and additional software that Fedora doesn’t want to ship, like MP3 codecs, Adobe Flash, Oracle Java etc. It can also fix problems, tweak and cleanup your system, show system information and much more with just few clicks.”

New Installation

The installation process is quite simple. Just enter the following in your terminal followed by the root password.

su -c "curl https://satya164.github.io/fedy/fedy-installer -o fedy-installer && chmod +x fedy-installer && ./fedy-installer"

Upgrading from FedoraUtils to Fedy

First you need to uninstall the fedoraultis from your system. For this, enter the following in your terminal followed by the root password.

sudo yum remove fedorautils

Then update the fedorautils repo.

sudo gedit /etc/yum.repos.d/fedorautils.repo

Delete everything in the file and add the following,

[fedorautils]
name=Fedora Utils
type=rpm-md
baseurl=http://download.opensuse.org/repositories/home:/satya164:/fedorautils/Fedora_$releasever/
gpgkey=http://download.opensuse.org/repositories/home:/satya164:/fedorautils/Fedora_$releasever/repodata/repomd.xml.key
gpgcheck=1
enabled=1
metadata_expire=1d
skip_if_unavailable=1

Save the file and install fedy by entering the following in the terminal.

sudo yum install fedy

I hope this will help a lot.