23

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" />
Sairam Krish
  • 10,158
  • 3
  • 55
  • 67
  • I am hitting the same issue , same OS - yosemite, Please let me know if you have fixed it – nondescript Jun 14 '15 at 02:32
  • hey guy, i have same issue on ubuntu 16.04, just install "sudo apt install lib32stdc++6 lib32z1" and now it's working, sorry i don't know how to install this library on osx – vuhung3990 May 10 '16 at 03:44

14 Answers14

34

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.

CapeCoder
  • 531
  • 6
  • 11
  • 2
    Linux : `./gradlew --info build clean` Thank you btw, you saved my day – Pierre Jun 06 '16 at 16:20
  • This command shows a clear error message. In my case, the error is "Invalid filename", and the file path was printed. This should be the best answer. – situee Jul 28 '16 at 08:11
  • From this, I found that the error was because a library wasn't installed, try: `sudo apt-get install zlib1g:i386` – Ben Winding Sep 29 '16 at 13:04
25

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.

Sairam Krish
  • 10,158
  • 3
  • 55
  • 67
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

Jeffrey Nicholson Carré
  • 2,950
  • 1
  • 26
  • 44
2

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

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

from my config.xml file

newari
  • 465
  • 4
  • 5
1

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.

C0ZEN
  • 894
  • 11
  • 41
1

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.

Alperzkn
  • 467
  • 2
  • 10
  • 25
  • Welcome to StackOverflow! From the first sentence of the question you can see that Mac Yosemite is being used. – Philipp Apr 06 '17 at 14:17
  • 1
    You are right, but i had same problem and I was looking for solution. I came here from Google, so if there are people like me maybe it would help them. That's why I wrote it. – Alperzkn Apr 06 '17 at 18:29
0

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

Darkowic
  • 661
  • 8
  • 17
0

Yes, Build successful after removing the below line

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

from config.xml

lakshman_dev
  • 94
  • 1
  • 12
0

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
Marcel Chastain
  • 2,101
  • 2
  • 18
  • 17
0

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
SylvainAr
  • 154
  • 5
0

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!

m.spyratos
  • 3,823
  • 2
  • 31
  • 40
0

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

Kaspi
  • 3,538
  • 5
  • 24
  • 29
0

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"/>
bCliks
  • 2,918
  • 7
  • 29
  • 52
-1

Try this (Worked for me):

  1. Uninstall Current JDK
  2. Install Latest JDK
  3. Run: cordova build --debug android
Milad Faridnia
  • 9,113
  • 13
  • 65
  • 78
sassouki
  • 1
  • 1