Wednesday 30 January 2013

Developing on Android on Fedora

The instructions for setting up Android development on Linux are pretty Ubuntu-centric. Here’s my basic set of steps to get things going on my shiny, new Fedora partition (which I have to say has been treating me much better — sorry, Ubuntu)!

1. Get Eclipse. Eclipse is available via yum on Fedora; there are even packages for plug-ins. That means you can grab most of what you need as easily as this:
su -c 'yum install eclipse-jdt eclipse-mylyn-java eclipse-mylyn eclipse-subclipse'
(I’m just throwing in a few plug-ins as examples, and very often you need Subversion support to easily pull in sample projects. eclipse-jdt is probably enough, however.)

2. Set the Sun JDK as a default. Okay, technically, you should be able to proceed with the OpenJDK, but you will want Sun JDK for Processing (which eventually we’ll use on Android), and I find it’s a smoother road – at least for now, as the last holes in OpenJDK get plugged.
Mauriat Miranda has written good instructions on how to set up Java and specifically how to configure Sun Java as a default. Just substitute the developer “JDK” for the runtime “JRE” – as on Windows, so long as you install the JDK, you’re set; you don’t need the JRE.

3. Set up Eclipse for its default plug-in repository. Okay, the one and only part of Fedora’s Eclipse setup that’s not very awesome is that it doesn’t set up the default plug-in location. That will mean some plug-in installers won’t be able to find dependencies. No worries, though: just go to Eclipse and select Help > Install New Software > Add… and enter this as a plug-in repository:
http://download.eclipse.org/releases/galileo

4. Install ADT. Set up the Android plug-in for Eclipse as per the usual instructions, with the installer at https://dl-ssl.google.com/android/eclipse/

5. Configure Fedora’s udev rules to support your device in debugging mode. Google correctly tells you to configure Linux so you can connect your phone for debugging, but it assumes you’re running Ubuntu. Here’s what worked for Fedora; perhaps folks familiar with other distros can tell me where else these apply.
You need to edit 51-android.rules, as on Ubuntu, as a super user:
su -
nano /etc/udev/rules.d/51-android.rules

Then add the line of code that will identify your device and place it in the proper mode. Make sure to match your device ID; “22b8″ is Motorola (for my Droid, or any other Moto handset). The list is at the bottom of the device developing page:
SUBSYSTEM=="usb",SYSFS{idVendor}=="22b8",SYMLINK+="android_adb",MODE="0666"
Finally, in place of the deprecated udevcontrol, reload instead with this:
udevadm control --reload-rules