Android SDK and NOEXEC tmp partition hint

If you’ve installed the Android SDK, but running the tools/android GUI fails with an error message when Java can’t find your SWT-GTK libraries, here’s a possible explanation: Your /tmp partition is mounted with the noexec option.

The error message in question looks like this:

[android-sdk-linux_86]$ tools/android 
Starting Android SDK and AVD Manager
No command line parameters provided, launching UI.
See 'android --help' for operations from the command line.
Exception in thread "main" java.lang.UnsatisfiedLinkError: no swt-gtk-3550 or swt-gtk in swt.library.path, java.library.path or the jar file
	at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
	at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
	at org.eclipse.swt.internal.C.(Unknown Source)
	at org.eclipse.swt.internal.Converter.wcsToMbcs(Unknown Source)
	at org.eclipse.swt.internal.Converter.wcsToMbcs(Unknown Source)
	at org.eclipse.swt.widgets.Display.(Unknown Source)

There are lots of reasons you could be seeing this exception — such as not having SWT installed at all! In my case, Java wasn’t finding SWT even though I was 100% sure I had installed Eclipse, the JDK and all the SWT libs correctly.

It turned out that the SWT shared libs were being copied to /tmp but because I’d mounted /tmp to a separate partition that’s mounted noexec,nosuid,nodev (an age-old UNIX security practice), they couldn’t be executed. Incidentally, the files in question are these:

[android-sdk-linux_86]$ ls /tmp/swtlib-32/

There may well be a better workaround, but my quick-and-dirty solution was to just edit the android/tools script and hardcode an alternate Java tmpdir (in this case, ~/tmp in my user directory). Just add a to the last line in android/tools, so that it looks something like this:

exec "$java_cmd" -Xmx256M $os_opts $java_debug"$progdir" -classpath "$jarpath:$swtpath/swt.jar" "$@"

Filed under: Systems.  Tagged: , .


Add a comment

You can also log in (or register) for easier commenting on lyncd.

Lyncd is an evolving group blog-in-progress. Weʼll be designing the site, adding users and content, and developing a hifalutin site focus as we go. For now, just think of our site mantra as “minimalism.” :)