ionic build android failure - Execution failed for

2020-01-31 02:36发布

问题:

I am using Mac Yosemite. Getting the following failure on running a build for android platform :

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processDebugResources'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /Users/sairamk/Development/android-sdk-macosx/build-tools/22.0.1/aapt package -f --no-crunch -I /Users/sairamk/Development/android-sdk-macosx/platforms/android-22/android.jar -M /Users/sairamk/projects/dummy_app/platforms/android/build/intermediates/manifests/full/debug/AndroidManifest.xml -S /Users/sairamk/projects/dummy_app/platforms/android/build/intermediates/res/debug -A /Users/sairamk/projects/dummy_app/platforms/android/build/intermediates/assets/debug -m -J /Users/sairamk/projects/dummy_app/platforms/android/build/generated/source/r/debug -F /Users/sairamk/projects/dummy_app/platforms/android/build/intermediates/res/resources-debug.ap_ --debug-mode --custom-package com.ionicframework.bcgsandbox553389 -0 apk --output-text-symbols /Users/sairamk/projects/dummy_app/platforms/android/build/intermediates/symbols/debug
  Error Code:
    1
  Output:
    /Users/sairamk/projects/dummy_app/platforms/android/build/intermediates/res/debug/xml/config.xml:59: error: Error parsing XML: unbound prefix

The build runs perfectly fine for IOS. I have installed android SDK and configured ANDROID_HOME and ANDROID_SDK_ROOT system variables.

Also tried removing the platform and adding it again, to have a clean platform folder using :

ionic platform remove android
ionic platform add android

But no good.

Android SDK build tool versions that I have installed - 19.1,20,21.1.2 and 22.0.1

AndroidManifest.xml preference :

 <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="22" />

回答1:

To get more info to debug this go in to the ./platforms/android/ folder and run:

Mac users:

gradlew --info build clean

Linux users (thanks Pierre):

./gradlew --info build clean

Windows users:

gradlew.bat --info build clean

This gives you a lot more detail.

My issue was solved this way, found some files that where incorrectly dropped into the project folder with spaces in the file names.



回答2:

This issue gets resolved by adding xml namespace for phonegap (xmlns:gap="http://phonegap.com/ns/1.0") to config.xml

After adding :

<widget id="com.ionicframework.yourpackagename" 
version="0.0.1" 
xmlns="http://www.w3.org/ns/widgets" 
xmlns:cdv="http://cordova.apache.org/ns/1.0"
xmlns:gap="http://phonegap.com/ns/1.0">

Hope it helps someone facing similar issue.



回答3:

from ionic forum

It was because of the "ionic resource" service error.

where run "ionic resource" command, I looked into and checked the /resources/android/splash folder, I clicked and open all of these png files, I found some pictures were broken(which appears as half of it).

So I replace these broken png files with the "normal" png file(at the same folder), then run "ionic build" command, the error is disappeared.

https://forum.ionicframework.com/t/ionic-android-build-problem/29131/7?u=bleuscyther



回答4:

But in my case, It resolved by removing the below line

    <gap:plugin name="nl.x-services.plugins.socialsharing" />

from my config.xml file



回答5:

I've got a similar issue. To find a workaround, I've created a new blank project. The compilation and emulation was good. I figure out there were a problem in my www folder. After some multiples test, one of my picture got that name : 'Clément.png". Removing the accent to get 'Clement.png' just fixed my problem.... A lot of pain.



回答6:

If you are developing with Windows, it may be because of the "path name". Windows doesn't allow the path name longer than 260 char. So making it shorter may solve it.



回答7:

I've got this problem on Arch Linux on clean Cordova. To debug this I followed @CapeCorder answer and found that this was missing zlib library. Simply installed it

sudo pacman -S lib32-zlib

And works well ;)



回答8:

Yes, Build successful after removing the below line

<gap:plugin name="nl.x-services.plugins.socialsharing" />

from config.xml



回答9:

Like some others, my error was caused by some terrible hidden files that were tripping gradle up.

In my case it was the special "Icon?" file that OSX creates inside of any folder that has a custom icon (such as Google Drive, Dropbox, etc). The file is actually named "Icon\r", and I believe java/gradle is tripping up over the "\r" (or any unexpected, unescaped character).

Solution was to nuke all the spurious "Icon?" files from my project directory:

# note that this is the syntax for zsh. 
# If you're using bash test out the pattern first before including '-delete'
find ~/code/myproject/ -name Icon$'\r' -delete


回答10:

I don't know why, but my android platform didn't work. Solved the problem by doing :

ionic platform rm android
ionic platform add android


回答11:

For me, turned out to be the long name length of some of the images I had inside the assets folder.

Just be aware. After deleting those images I was still getting the same error. The reason being that the images persisted inside the www folder. Deleted that folder and worked!



回答12:

I use Vue.js and Webpack to generate production files and the output contains *.gz files, which was the problem if put into Cordova's www/.



回答13:

In my case, it was pushwoosh plugin.

<gap:plugin name="pushwoosh-phonegap-plugin">

We don't need to remove the plugin. Just set the version of plugin which is worked last time. This is worked for me.

<gap:plugin name="pushwoosh-phonegap-plugin"  spec="7.0.4" source="npm"/>


回答14:

Try this (Worked for me):

  1. Uninstall Current JDK
  2. Install Latest JDK
  3. Run: cordova build --debug android