May 6, 2012

Setting up the Android SDK on Fedora Linux

Some resources I have found helpful:

Java

Android development is all about Java, and the Google notes for the android SDK tell me I will need Java and Eclipse. We will get to Eclipse later. I have gone around the tree with Java on linux before: As always there are too many choices and insufficient advice for a person just starting out. I am told (by the Google install instructions for the Android SDK) that I need the actual Sun/Oracle 7 JDK installed. The Gnu GCJ definitely will not do (at the time of this writing). Apparently some people manage with OpenJDK (which ships with Fedora). What I am told is that "OpenJDK" is the open source Java that was/is released by Sun/Oracle and should be virtually identical to the real deal. The big advantage of OpenJDK is that it is available out of the box via yum for fedora, it is the default java, and will be kept up to date by the yum package system without pain.

Going with OpenJDK might have been the smarter choice.

Google says that you must be able to run 32 bit apps on your linux host, but it turns out this has nothing to do with Java, and it is perfectly right to install 64 bit java on a 64 bit machine.

rpm -Uvh jdk-7-linux-x64.rpm
I downloaded and installed this back in September of 2011. In May of 2012, I downloaded it again, and verified that the package contents had not changed.

Note that what used to be called the "SDK" is now called the "JDK". Also note that the JDK contains the JRE, so if you install the JDK, you do not also need to install the JRE.

After this you need to fight with the Fedora "alternatives" system to make this java the one you actually use (rather than OpenJDK), see my notes linked to above for details on this.

Eclipse

I am told that I also need eclipse, and that the package to install is eclipse-jdt. "JDT" stands for Java Development Tools.
This is easy:
yum install eclipse-jdt
Once you have this, you are encouraged to also install the "ADT" plugin for eclipse from google ("ADT" stands for Android Development Tools).

The Android SDK

I downloaded from the above link, the file: android-sdk_r18-linux.tgz, then untarred this into /u1/android/android-sdk-linux. Then I made the links:
su
cd /opt
ln -s /u1/android/android-sdk android
ln -s /u1/android/android-sdk-linux androidSDK
It remains to be seen whether the /opt/android link has any utility. If not, I should have made /opt/android point to the SDK (and I may change it so that is how it is).

Then I edited my .bashrc and added the following two directories to my path:

/opt/androidSDK/tools
/opt/androidSDK/platform-tools
I used the moral equivalent of this:
export PATH=$PATH:/opt/AndroidSDK/platform-tools:/opt/AndroidSDK/tools
After doing this, when I log out and back in again, I can type android and get the android SDK manager.

Install more stuff using the SDK manager

At this point, I have critical mass of sorts and can start using the Android SDK itself to load the rest of what I need.
I intend to be developing for my Motorola Xoom, which is running Android 4.0.4 as of 5-7-2012

It tells me an update to r19 of the SDK tools is available.
The SDK for "API 15" (i.e. Android 4.0.3) is the latest thing available.
I select "extras" and "platform tools", which makes for 15 packages for it to install. It is placing them into /opt/androidSDK.
Away we go, this is going to take a long time.
Once the dust settles, we have:

I don't know if I need any of the extras (although Android support looks useful), but I got them in any case.

Android Emulator

The next thing is to set up an "AVD" (Android Virtual Device). I was getting errors until I realized that this is the part that requires running 32 bit executables and having 32 bit support libraries. The errors I was getting were complaints that it could not create files in the AVD directory, after installing the following 32 bit libraries, it all works:
yum install glibc.i686 glibc-devel.i686 libstdc++.i686 zlib-devel.i686 ncurses-devel.i686 libX11-devel.i686 libXrender.i686 libXrandr.i686 
To create an android virtual device, use the android command, then use Tools-->Manage AVD's. This will bring up the Android Virtual Device Manager. Use the "NEW" button, fill in the form, then start and launch the virtual device to ensure that it all works.

The Eclipse ADT plugin

Eclipse takes forever to start, I imagine people who use it just leave it running all the time it is so bad. I imagine the long delay is just to show off the splash screen. This may not be so, there are lots of tips online about how to speed things up.

I tell it to use /home/tom/android as a workspace.

Use Help-->"Install New Software" to bring up a "Install" window, then use the "ADD" button to create a new repository for "ADT Plugin" with the URL

https://dl-ssl.google.com/android/eclipse/
Also activate http://download.eclipse.org/releases/helios which should be in the menu of available sites) by clicking on the checkbox next to it.

Then with these two repositories selected, install all software. It is ready to install:

Once this is done, I restart eclipse and use Preferences to select Android as my default.

USB setup

I plug in my Xoom (even when powered off!) while watching /var/log/messages and see:
 usb 1-6: new high-speed USB device number 3 using ehci_hcd
 usb 1-6: New USB device found, idVendor=22b8, idProduct=70a8
 usb 1-6: New USB device strings: Mfr=2, Product=3, SerialNumber=4
 usb 1-6: Product: MZ604
 usb 1-6: Manufacturer: Motorola
 usb 1-6: SerialNumber: 0380624640e04217

Hello World for the Android Virtual Device

I select File-->New-->Android Project
Have any comments? Questions? Drop me a line!

Adventures in Computing / tom@mmto.org