在ubuntu64位机上编译android源码之后,执行WORKING_DIRECTORY/out/host/linux-x86/bin/ 下面的android命令 或android avd等命令时会提示:
SWT folder WORKING_DIRECTORY/out/host/linux-x86/framework/x86-64 does not exist.
Please export ANDROID_SWT to point to the folder containing swt.jar for your platform.
进入WORKING_DIRECTORY/out/host/linux-x86/framework查看,发现确实没有x86-64文件夹,于是网上下载64位的SWT库文件,并放在X86-64文件夹下。重新运行android命令,结果提示:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Cannot load 32-bit SWT libraries on 64-bit JVM
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.showSdkManagerWindow(Main.java:334)
at com.android.sdkmanager.Main.doAction(Main.java:322)
at com.android.sdkmanager.Main.run(Main.java:119)
at com.android.sdkmanager.Main.main(Main.java:102)
明明已经加入了64bit的swt.jar怎么会还是提示无法加载32bit的SWT库呢?于是查看android命令的源文件,发现倒数第二行有:
-classpath "$jarpath:$swtpath/swt.jar" \
其中变量$jarpath 表示的~/WORKING_DIRECTORY/out/host/linux-x86/framework/sdkmanager.jar:~/WORKING_DIRECTORY/out/host/linux-x86/framework/swtmenubar.jar
又发现在framework中有一个32bit版本的swt.jar,是不是java会默认先从当前目录中查找呢?于是把framework中的那个32bit的swt.jar删除,在shell中再次运行android命令,弹出了sdkmanager的对话框,就这样问题真的解决啦!原来是framework文件夹中那个32bit的swt.jar造成的原因。