昨天終於升級了下Ubuntu系統到16.04LTS,之前是12.04LTS(導致內網一些同事開發的網址無法打開,以及其他工具軟件無法安裝)。
安裝完android開發工具,運行之前的project,出現如下的錯誤:
FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':compileDebugAidl'. > java.lang.RuntimeException: com.android.ide.common.process.ProcessException: Error while executing '/opt_dev/android-sdk-linux_new/build-tools/23.0.3/aidl' with arguments {-p/opt_dev/android-sdk-linux_new/platforms/android-26/framework.aidl -o/home/dream/workspace/NewUserHomePage/build/generated/source/aidl/debug} * Try:
google了下,網上的錯誤跟這個還不一樣都是missing aidl 替換或者重新安裝build tools版本即可,在stackoverflow上有個人跟我一樣的問題,但是沒有人回復。
我以為是我的sdk的問題,這個sdk來自之前的系統安裝的,所以重新下了個sdk,還是出現這樣的錯誤。
接着懷疑是不是android studio/gradle的問題,都重新部署了,還是有問題。
后來,在android studio 中點開Gradle console,才終於找到問題所在:
:compileDebugAidl /opt_dev/android-sdk-linux_new/build-tools/23.0.3/aidl: error while loading shared libraries: libgcc_s.so.1: cannot open shared object file: No such file or directory /opt_dev/android-sdk-linux_new/build-tools/23.0.3/aidl: error while loading shared libraries: libgcc_s.so.1: cannot open shared object file: No such file or directory FAILED /opt_dev/android-sdk-linux_new/build-tools/23.0.3/aidl: error while loading shared libraries: libgcc_s.so.1: cannot open shared object file: No such file or directory /opt_dev/android-sdk-linux_new/build-tools/23.0.3/aidl: error while loading shared libraries: libgcc_s.so.1: cannot open shared object file: No such file or directory
直覺是,這個aidl共享庫引用了32位的libgcc_s.so,但是系統里面沒有這個,所以運行如下的命令:
sudo apt-get install lib32gcc1
重新build,OK了
奇怪的是,我之前安裝過32位的兼容so了啊,可能不全吧
android sdk的很多so或者工具都是基於32位系統開發的,而Ubuntu 16.04 是64位系統(可以運行 uname -a 來查看,有x86_64的就是了),所以需要安裝一些32位的so