Wednesday, October 19, 2011

Compiling with Android ADT 14

Hong Kong is not so far away when the live video feed is broadcasting the announcement of all the latest Android goodness from the illustrious Ice Cream Sandwich release right to my laptop. Perhaps more importantly, the new Android SDK and developer tools is even closer by once I had downloaded the newly available releases to my Eclipse installation.

Actually using these tools, however, couldn't have felt further away when I launched my app only to be greeted with the dreaded "Conversion to Dalvik format failed" error message. Yikes!

Fortunately, the Android community is an active one, and an issue was posted fairly quickly with a follow-up workaround to the issue. The problem that I had encountered was that the OpenFeint libraries that my project depended on had duplicate classes that ended up conflicting with each other, perhaps because one of these libraries in turn depended upon the other (GameFeed on the main OpenFeint library). The solution was to removed duplicate references of these libraries to ensure that there were no conflicts. Here are the steps I took for my project
  • Open the .project file for my project, which may not be visible in the Eclipse project explorer but is in the project's root directory as found through a normal file browser.
  • Remove the entire <linkedResources> section.
  • Refresh the project (File > Refresh).
  • Navigate to Project > Properties > Java Build Path > Source and remove the library folders, which will probably be conveniently highlighted in red now that their reference as linked resources has been removed.
  • Repeat for any library that depends on another library included in the project.

My project now compiled fine for debugging. While exporting my project, I again ran into the Dalvik conversion error, but this time for an old rather than a new problem. Back when Android SDK Tools R12 was released, a bug was reported where projects failed to export because an older, incompatible version of ProGuard was included with Tools. The workaround was to download ProGuard 4.6 directly from its maker and replace the proguard.jar file. After upgrading to ADT 14/SDK 14, my manually-upgraded ProGuard file got replaced with the older version, and I had to swap it back. Here are the steps:
  • Download ProGuard 4.6 directly and unpack it.
  • Navigate to android-sdk-[platform]\tools\proguard\lib (eg in the android-sdk-windows folder).
  • Replace the proguard.jar file with the one from your newly downloaded ProGuard 4.6 folder.
  • Refresh the project and export it!
I hope these tips will get you up and running on the latest Android ADT and Tools, even if you (as I) don't yet have a device running Ice Cream Sandwich. And now, time for me to grab some midday dessert...
Post a Comment