Advertisements

Too Many Bits for DDMS

Tips & Tools Too Many Bits for DDMS

If you’re like me, you do your Android development outside Eclipse and therefore rely upon the full range of the Android toolkit, from activitycreator through DDMS. And, if you’re like me, you just plopped a 64-bit Linux (Ubuntu 8.10 “Intrepid Ibex”) on a multi-core PC for development work.

Which means, if you’re like me, you ran into a problem trying to get DDMS to run.

DDMS appears to be written using the Eclipse’s SWT GUI toolkit. The version of the SWT that ships with Android 1.0r2 is written for a 32-bit Java runtime. If you try running it on a 64-bit Java VM, you get a nasty error like “wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch)” coming out of one of the RCP libraries (tools/lib/libswt-pi-gtk-3236.so).

I am sure there are any number of elegant ways to get around this that allow DDMS to run as 32-bit Java while the rest of your environment is 64-bit Java. However, I couldn’t find any. So, here’s a brute-force way to do it.

First, you need a 32-bit Java runtime. In Debian/Ubuntu, this is in the ia32-java-6-sun package. Install that using your favorite packaging tool (Synaptic, aptitude, apt-get, etc.).

You can then use update-java-alternatives –list to confirm that your 64-bit JDK is there, but the 32-bit JRE is also available. It should also have left alone your default Java (the one invoked when you run java at the command line).

Next, you need to teach DDMS to use the 32-bit Java instead of the default. Use update-java-alternatives –list to determine the path to your 32-bit Java runtime (e.g., /usr/lib/jvm/ia32-java-6-sun/bin/java). Then, make a copy of tools/ddms from your Android runtime and modify it, changing the value of java_cmd to match your 32-bit JRE location (e.g., java_cmd=”/usr/lib/jvm/ia32-java-6-sun/bin/java”).

Try it out, and DDMS should fire up just fine. Since it coordinates with devices and emulators using sockets or USB drivers, the fact that it is 32-bit does not affect its ability to interoperate with your other tools.

Of course, you have to remember to use your modified DDMS (e.g., set up a launcher for it on your desktop or a GNOME panel). And, you may need to repeat these steps, or ones like them, in future Android SDK releases, until DDMS is shipped in a way that works out of the box for both 32-bit and 64-bit Java.

Have a cleaner way to fix this problem? Post a comment and let us know!

AndroidGuys
Since 2007 we have offered news and opinion around Android, the mobile space, and connected homes. We aim to help users get more from their smartphones and hope to be a valuable resource for future purchases.