lyncd

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)
	at com.android.sdkmanager.Main.showMainWindow(Main.java:292)
	at com.android.sdkmanager.Main.doAction(Main.java:276)
	at com.android.sdkmanager.Main.run(Main.java:99)
	at com.android.sdkmanager.Main.main(Main.java:88)

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/
libswt-gtk-3550.so  libswt-pi-gtk-3550.so

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 -Djava.io.tmpdir=/path/to/some/tmpdir to the last line in android/tools, so that it looks something like this:

exec "$java_cmd" -Djava.io.tmpdir=/home/sticks/tmp -Xmx256M $os_opts $java_debug -Dcom.android.sdkmanager.toolsdir="$progdir" -classpath "$jarpath:$swtpath/swt.jar" com.android.sdkmanager.Main "$@"

Filed under: Systems.  Tagged: , .

3 comments »

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.” :)