Cannot run program “/opt/android-sdk/platform-tools/aapt”

It seems that Google did a big reorg of the Android SDK file tree, and some tools still expect things in the old locations, like our Jenkins build server:

FATAL: Cannot run program "/opt/android-sdk/platform-tools/aapt" (in directory ": java.io.IOException: error=2, No such file or directory
java.io.IOException: Cannot run program "/opt/android-sdk/platform-tools/aapt" (in directory ": java.io.IOException: error=2, No such file or directory
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:488)
	at hudson.Proc$LocalProc.(Proc.java:244)
	at hudson.Proc$LocalProc.(Proc.java:216)
	at hudson.Launcher$LocalLauncher.launch(Launcher.java:763)
	at hudson.Launcher$ProcStarter.start(Launcher.java:353)
	at hudson.Launcher$ProcStarter.join(Launcher.java:360)
	at hudson.plugins.android_emulator.util.Utils.runAndroidTool(Utils.java:420)
	at hudson.plugins.android_emulator.util.Utils.runAndroidTool(Utils.java:398)
	at hudson.plugins.android_emulator.builder.AbstractBuilder.getPackageIdForApk(AbstractBuilder.java:248)
	at hudson.plugins.android_emulator.builder.AbstractBuilder.uninstallApk(AbstractBuilder.java:198)
	at hudson.plugins.android_emulator.InstallBuilder.perform(InstallBuilder.java:96)
	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:802)
	at hudson.model.Build$BuildExecution.build(Build.java:199)
	at hudson.model.Build$BuildExecution.doRun(Build.java:160)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:584)
	at hudson.model.Run.execute(Run.java:1575)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
	at hudson.model.ResourceController.execute(ResourceController.java:88)
	at hudson.model.Executor.run(Executor.java:237)
Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
	at java.lang.UNIXProcess.(UNIXProcess.java:164)
	at java.lang.ProcessImpl.start(ProcessImpl.java:81)
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:470)
	... 19 more

Luckily there are symlinks! This fixed it for me:


cd /opt/android-sdk
ln -s 18.0.1 build-tools/current
ln -s ../build-tools/current/aapt platform-tools/aapt
ln -s ../build-tools/current/lib platform-tools/lib

Then whenever the build-tools get updated, just the symlink in /opt/android-sdk/build-tools/current needs to be updated. This is a little improvement on the solution found here.

Advertisements

You must be logged in to post a comment.

%d bloggers like this: