Cordova build android error Execution failed for t

2019-02-26 21:29发布

I am developing an hybrid mobile app for android and ios with cordova, angularjs and angularmaterial design. I use npm, bower and grund to manage and run build task. I could build ios but not android with error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: 
Process 'command '/xxx/android-sdk/build-tools/23.0.3/aapt'' 
finished with non-zero exit value 1

* 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: 1 mins 0.919 secs
Error: Error code 1 for command: /xxx/platforms/android/gradlew with args: cdvBuildDebug,-b,/xxx/platforms/android/build.gradle,-Dorg.gradle.daemon=true,-Pandroid.useDeprecatedNdk=true.

My environments:

  • cordova@6.1.0
  • node_modules node packages
  • bower_components dependencies with bowers
  • angularjs and angular material design

Any help is appreciated.

ps: I run

cordova platform add android
cordova build android

I even tried to remove/add the android but still no luck.

One interesting observe, If I use a blank project then It will be built successfully for both platforms

Thanks

3条回答
小情绪 Triste *
2楼-- · 2019-02-26 21:51

Try adding xml namespace for phonegap (xmlns:gap="http://phonegap.com/ns/1.0") to config.xml

查看更多
Root(大扎)
3楼-- · 2019-02-26 21:52

I found the issue. I have node_moudles and bower_components inside the www of Cordova project. After moving my nodejs dependencies from www and and remvoe the bower_components folder and try bower install again it works.

I don't really understand what the cordova build android running behind the scene that cause error when having node_modules inside the www.

FYI I just used npm to manage dependency for my development(karma, grunt, httpserver, ...). It is even better to move it from the www.

查看更多
Anthone
4楼-- · 2019-02-26 22:05

For me the problem was caused by the bower_components. I used the "bower link" command to reference a local bower package so I could work on this simultaneously. But when I tried to build to Android, the build failed with the same error message. Using

bower unlink YOUR_PACKAGE_NAME

(or just removing the 'bower_components' directory) and then reinstalling the packages by

bower install

fixed this issue.

查看更多
登录 后发表回答