我最近想尝试离子并专门开发Android应用程序。我能够使用离子教程设置所有内容并通过localhost运行。我希望能够使用Android模拟器做同样的事情,但一直没有成功。我搜索并尝试了一切,但我仍然不确定如何解决下面的错误。所有代码都来自离子入门页面,其项目名为todo。如果有人可以帮我这个。非常感谢。我正在使用Ubuntu。以下是我的终端在运行" ionic build android"
时给出的内容FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':CordovaLib:processDebugResources'.
> com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException:
Process 'command '/home/myname/Android/Sdk/build-tools/24.0.0/aapt''
finished with non-zero exit value 127
* 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: 37.93 secs
Error: Error code 1 for command: /home/myname/todo/platforms/android
/gradlew with args: cdvBuildDebug,-b,/home/myname/todo/platforms
/android/build.gradle,-Dorg.gradle.daemon=true,
Pandroid.useDeprecatedNdk=true
编辑1: 我运行了以下建议:./gradlew assembleDebug -info,我收到以下错误:
:CordovaLib:processDebugResources
Executing task ':CordovaLib:processDebugResources' (up-to-datecheck
took 0.058 secs) due to:
No history is available.
All input files are considered out-of-date for incremental task
':CordovaLib:processDebugResources'.
Starting process 'command '/home/myname/Android/Sdk/build-tools/24.0.0
/aapt''. Working directory: /home/myname/todo/platforms/android
/CordovaLib Command: /home/myname/Android/Sdk/build-tools/24.0.0/aapt
package -f --no-crunch -I /home/myname/Android/Sdk/platforms/android-
23/android.jar -M /home/myname/todo/platforms/android/CordovaLib/build
/intermediates/bundles/debug/aapt/AndroidManifest.xml -S /home/myname
/todo/platforms/android/CordovaLib/build/intermediates/bundles/debug/res
-A /home/myname/todo/platforms/android/CordovaLib/build/intermediates
/bundles/debug/assets -m -J /home/myname/todo/platforms/android
/CordovaLib /build/generated/source/r/debug --debug-mode --custom-
package
org.apache.cordova --non-constant-id -0 apk --output-text-symbols
/home/myname/todo/platforms/android/CordovaLib/build/intermediates
/bundles /debug
Successfully started process 'command '/home/myname/Android/Sdk/build-
tools/24.0.0/aapt''
Unknown source file : /home/myname/Android/Sdk/build-tools/24.0.0/aapt:
1: /home/myname/Android/Sdk/build-tools/24.0.0/aapt: ELF: not
found :CordovaLib:processDebugResources FAILED
从我看到的我明白aapt文件有问题,如果我删除它会抛出错误,所以我不知道如何编辑aapt文件
答案 0 :(得分:1)
这可能与项目中某处的文件名错误有关。 要查看文件中的错误,
通过终端转到你的android文件夹,
/projectName/platforms/android
然后,执行gradlew assembleDebug --info
它应该显示到底是哪个文件。
- 编辑
这可能与Ubuntu不兼容问题有关,
根据https://stackoverflow.com/a/27734148/2036808
$ sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 lib32stdc++6
答案 1 :(得分:1)
在同一期间花了好几个小时后,通过运行一些更新解决了问题:
npm update -g ionic cordova
此信息位于:https://forum.ionicframework.com/t/android-build-failed/32069