Ionic Android Build Fails CordovaLib:processDebugR

2019-03-04 03:49发布

问题:

I recently wanted to try out ionic and specifically develop android apps. I was able to set everything up using the ionic tutorial and run via localhost. I want to be able to do the same using the android emulator but have been unsuccessful. I have searched and tried everything but I am still not sure how to resolve the error below. All the code is from the ionic getting started page with their project called todo. If anyone could help me with this. it would be much appreciated. I am using Ubuntu. The following is what my terminal gives when I run "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

Edit 1: I ran the following command suggested below: ./gradlew assembleDebug -info and I get the following error:

: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

From what I see I understand that something is wrong with the aapt file, If I remove it it throws errors, so I am not sure how to edit the aapt file

回答1:

This could be related to a filename error somewhere in your project. To see where the error in file is,

go to your android folder via terminal, /projectName/platforms/android

Then, execute gradlew assembleDebug --info

It should show in the end which file it is.

-- EDIT

This could be related to Ubuntu incompatibility problems,

As per https://stackoverflow.com/a/27734148/2036808

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


回答2:

After hours spent in the same issue, just solved the problem by running some updates:

npm update -g ionic cordova

This information was found at: https://forum.ionicframework.com/t/android-build-failed/32069