简体   繁体   中英

ionic build android failure - Execution failed for task processDebugResources

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" />

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.

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.

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

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

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

from my config.xml file

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.

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.

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 ;)

Yes, Build successful after removing the below line

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

from config.xml

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

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

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!

我使用Vue.js和Webpack生成生产文件,输出包含* .gz文件,如果放入Cordova的www /中则会出现问题。

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"/>

Try this (Worked for me):

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM