Error: java.io.IOException: build on Android device failed at task 'processDebugResources'

Error: java.io.IOException: build on Android device failed at task 'processDebugResources'

我正在使用 Ubuntu 12.04.4 LTS,我的 android phone 是

Samsung Galaxy S3 Neo I93001 Android 版本 4.3 并成功连接到设备。

~$ adb devices
List of devices attached
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
4e1eb1e1    device

尝试在 android 设备中构建示例应用程序时出现此错误。

Execution failed for task ':CordovaLib:processDebugResources'.

java.io.IOException: Cannot run program "/android-sdk-linux/build-tools/23.0.2/aapt": error=2, No such file or directory

Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

~/socially1-3$ meteor run android-device --verbose

Getting installed version for platform android in Cordova project
Checking Cordova requirements for platform Android
[[[[[ /socially1-3 ]]]]]

=> Started proxy. 
=> Started MongoDB. 
Local package version is up-to-date: accounts-base@1.2.2
....
Local package version is up-to-date: webapp-hashing@1.0.5

Preparing Cordova project from app bundle 
Processing mobile-config.js 
Copying resources for mobile apps 
Writing new config.xml 
Preparing Cordova project for platform Android

WARNING: You are testing your app on a remote device. For the mobile app to be able to connect to the local server, make sure your device is on
the same network, and that the network configuration allows clients to talk to each other (no client isolation).
Running Cordova app for platform Android with options --device
ANDROID_HOME=/android-sdk-linux
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64

Running: /socially1-3/.meteor/local/cordova-build/platforms/android/gradlew cdvBuildDebug -b /socially1-3/.meteor/local/cordova-build/platforms/android/build.gradle -PcdvBuildArch=arm -Dorg.gradle.daemon=true
=> Started your app.

=> App running at: http://localhost:3000/ 
:preBuild
:compileDebugNdk UP-TO-DATE
:preDebugBuild
:checkDebugManifest
:CordovaLib:compileLint
:CordovaLib:copyDebugLint UP-TO-DATE
:CordovaLib:mergeDebugProguardFiles UP-TO-DATE
:CordovaLib:preBuild
:CordovaLib:preDebugBuild
:CordovaLib:checkDebugManifest
:CordovaLib:prepareDebugDependencies
:CordovaLib:compileDebugAidl UP-TO-DATE
:CordovaLib:compileDebugRenderscript UP-TO-DATE
:CordovaLib:generateDebugBuildConfig UP-TO-DATE
:CordovaLib:generateDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugAssets UP-TO-DATE
:CordovaLib:generateDebugResValues UP-TO-DATE
:CordovaLib:generateDebugResources UP-TO-DATE
:CordovaLib:packageDebugResources UP-TO-DATE
:CordovaLib:processDebugManifest UP-TO-DATE
:CordovaLib:processDebugResources FAILED

FAILURE: Build failed with an exception.

What went wrong:
Execution failed for task ':CordovaLib:processDebugResources'.

java.io.IOException: Cannot run program "/android-sdk-linux/build-tools/23.0.2/aapt": error=2, No such file or directory
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 29.25 secs
Starting app on Android Device \
/socially1-3/.meteor/local/cordova-build/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /socially1-3/.meteor/local/cordova-build/platforms/android/gradlew with args: cdvBuildDebug,-b,/socially1-3/.meteor/local/cordova-build/platforms/android/build.gradle,-PcdvBuildArch=arm,-Dorg.gradle.daemon=true
=> Errors executing Cordova commands:

While running Cordova app for platform Android with options --device:
Error: Command failed: /socially1-3/.meteor/local/cordova-build/platforms/android/cordova/run
--device

at ChildProcess.exitCallback (/tools/utils/processes.js:137:23)
at ChildProcess.emit (events.js:98:17)
at Process.ChildProcess.handle.onexit (childprocess.js:820:12)

ExitWithCode:1

我首先想到的是文件“aapt”不可用或者该文件没有权限。但是 'aapt' 文件在指定路径下可用,用户也有读写权限。

您正在尝试 运行 64 位系统上的 32 位文件。尝试

>file aapt

它应该给你以下结果

aapt: ELF 32-bit LSB shared object ...

SDK 管理器实际上正在安装 32 位文件..

试试这个修复:

(Using software centre or command lines) If your Ubuntu is a 32-bit OS then install libgl1-mesa-dev

In case of 64-bit OS install ia32-libs (Ubuntu 13.04 or earlier), or libgl1-mesa-dev:i386 (Ubuntu 13.10 and above)

参考:https://askubuntu.com/questions/318246/complete-installation-guide-for-android-sdk-adt-bundle-on-ubuntu

根据 Android 开发者网站,

注:
如果你是 运行 64 位版本的 Ubuntu,你需要使用以下命令安装一些 32 位库:

sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 lib32stdc++6

如果你是运行64位Fedora,命令是:

sudo yum install zlib.i686 ncurses-libs.i686 bzip2-libs.i686

按照link安装步骤:
https://developer.android.com/studio/install.html