Ionic: execution failed for task ' processdebugresources' - android

All the things happened after I made several commands for the ionic App with ngCordova
- ionic start "App Project Name"
- ionic platform add android
- ionic build android
:processDebugResources Unable to add '/Users/desmondlai/Desktop/hairCorner/HairProject/platforms/android/build/intermediates/assets/debug/www/node_modules/try-thread-sleep/node_modules/thread-sleep/node_modules/node-pre-gyp/node_modules/tar-pack/test/fixtures/packed.tar.gz': file already in archive (try '-u'?)
ERROR: unable to process assets while packaging '/Users/desmondlai/Desktop/hairCorner/HairProject/platforms/android/build/intermediates/res/resources-debug.ap_'
ERROR: packaging of '/Users/desmondlai/Desktop/hairCorner/HairProject/platforms/android/build/intermediates/res/resources-debug.ap_' failed
FAILED
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/desmondlai/Library/Android/sdk/build-tools/23.0.2/aapt package -f --no-crunch -I /Users/desmondlai/Library/Android/sdk/platforms/android-22/android.jar -M /Users/desmondlai/Desktop/hairCorner/HairProject/platforms/android/build/intermediates/manifests/full/debug/AndroidManifest.xml -S /Users/desmondlai/Desktop/hairCorner/HairProject/platforms/android/build/intermediates/res/debug -A /Users/desmondlai/Desktop/hairCorner/HairProject/platforms/android/build/intermediates/assets/debug -m -J /Users/desmondlai/Desktop/hairCorner/HairProject/platforms/android/build/generated/source/r/debug -F /Users/desmondlai/Desktop/hairCorner/HairProject/platforms/android/build/intermediates/res/resources-debug.ap_ --debug-mode --custom-package com.ionicframework.starter -0 apk --output-text-symbols /Users/desmondlai/Desktop/hairCorner/HairProject/platforms/android/build/intermediates/symbols/debug
Error Code:
1
Output:
Unable to add '/Users/desmondlai/Desktop/hairCorner/HairProject/platforms/android/build/intermediates/assets/debug/www/node_modules/try-thread-sleep/node_modules/thread-sleep/node_modules/node-pre-gyp/node_modules/tar-pack/test/fixtures/packed.tar.gz': file already in archive (try '-u'?)
ERROR: unable to process assets while packaging '/Users/desmondlai/Desktop/hairCorner/HairProject/platforms/android/build/intermediates/res/resources-debug.ap_'
ERROR: packaging of '/Users/desmondlai/Desktop/hairCorner/HairProject/platforms/android/build/intermediates/res/resources-debug.ap_' failed
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: 45.169 secs
/Users/desmondlai/Desktop/hairCorner/HairProject/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Users/desmondlai/Desktop/hairCorner/HairProject/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/desmondlai/Desktop/hairCorner/HairProject/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/desmondlai/Desktop/hairCorner/HairProject/platforms/android/cordova/build: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: /Users/desmondlai/Desktop/hairCorner/HairProject/platforms/android/cordova/build: Command failed with exit code 1

Add/remove android didn't fix the problem for me either.
Generating the project resources fixed the issue for me.
ionic resources

Add xml namespace xmlns:gap="http://phonegap.com/ns/1.0" to your config.xml
also, if you are using linux you must do "sudo chmod 755 gradlew" before you do the "./gradlew clean" to make sure it is executable

delete your icon folder splashscreen folder
then follow these commands
sudo npm install ionic-resources -g
ionic resources android

Related

libpng error: Read Error while building ionic for android

I am getting this error when i build for android -
ionic build android
error -
`AAPT err(Facade for 259068547): libpng error: Read Error
AAPT err(Facade for 1123857185): libpng error: Read Error
AAPT err(Facade for 594029608): libpng error: Read Error
FAILED
FAILURE:
Build failed with an exception.
What went wrong:
Execution failed for task ':mergeArmv7DebugResources'.
>
Some file crunching failed, see logs for details
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: 6.193 secs
Error: Error code 1 for command: cmd with args: /s,/c,"f:\D\srcc\proj\platforms\
android\gradlew cdvBuildDebug -b f:\D\srcc\proj\platforms\android\build.gradle -
Dorg.gradle.daemon=true -Pandroid.useDeprecatedNdk=true"`
How can i find the exact error or solve this issue? Anyone please?
I also meet this build fail problem due to I run ionic resources, at this time my ionic version is 2.1.1, I find there is something wrong with one image in the path resources\android\splash incomplete image
after I run npm uninstall ionic -g and reinstall it, now version is 2.1.14, then delete the folder resources\android run ionic resources android --force and ionic build android , the problem is solved.

Ionic Android Build Fails CordovaLib:processDebugResources

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

Android Build failed - Ionic / Cordova - Unable to add asset file - file already in archive

Got this error:
Unable to add '/Users/MRW/Desktop/Work/niv/extern/mobile-app/platforms/android/build/intermediates/assets/debug/www/lib/angular-localization/angular-localization.min.js.gz': file already in archive (try '-u'?)
ERROR: unable to process assets while packaging '/Users/MRW/Desktop/Work/niv/extern/mobile-app/platforms/android/build/intermediates/res/resources-debug.ap_'
ERROR: packaging of '/Users/MRW/Desktop/Work/niv/extern/mobile-app/platforms/android/build/intermediates/res/resources-debug.ap_' failed
:processDebugResources FAILED
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/MRW/Library/Android/sdk/build-tools/23.0.1/aapt package -f --no-crunch -I /Users/MRW/Library/Android/sdk/platforms/android-22/android.jar -M /Users/MRW/Desktop/Work/niv/extern/mobile-app/platforms/android/build/intermediates/manifests/full/debug/AndroidManifest.xml -S /Users/MRW/Desktop/Work/niv/extern/mobile-app/platforms/android/build/intermediates/res/debug -A /Users/MRW/Desktop/Work/niv/extern/mobile-app/platforms/android/build/intermediates/assets/debug -m -J /Users/MRW/Desktop/Work/niv/extern/mobile-app/platforms/android/build/generated/source/r/debug -F /Users/MRW/Desktop/Work/niv/extern/mobile-app/platforms/android/build/intermediates/res/resources-debug.ap_ --debug-mode --custom-package com.ionicframework.gtrackerde947201 -0 apk --output-text-symbols /Users/MRW/Desktop/Work/niv/extern/mobile-app/platforms/android/build/intermediates/symbols/debug
Error Code:
1
Output:
Unable to add '/Users/MRW/Desktop/Work/niv/extern/mobile-app/platforms/android/build/intermediates/assets/debug/www/lib/angular-localization/angular-localization.min.js.gz': file already in archive (try '-u'?)
ERROR: unable to process assets while packaging '/Users/MRW/Desktop/Work/niv/extern/mobile-app/platforms/android/build/intermediates/res/resources-debug.ap_'
ERROR: packaging of '/Users/MRW/Desktop/Work/niv/extern/mobile-app/platforms/android/build/intermediates/res/resources-debug.ap_' failed
* 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: 19.601 secs
/Users/MRW/Desktop/Work/niv/extern/mobile-app/platforms/android/cordova/node_modules/q/q.js:126
Can someone please help me? i tried:
reinstall android sdk
install it with android studio
reinstall cordova
reinstall ionic
clear platform folder of project
:( i cant find an answer with google...
You should not remove your platform folder. Problem found and it is www/lib/ directory of your project.
Some packages provided by npm, bower and another managers, contains both version for some files - original and gzipped.
In your output log i see problem assigned with www/lib/angular-localization/angular-localization.min.js.gz
Check this file and you'll find out angular-localization.min.js (without .gz extension) amy be.
For example my recent problem with www/node_modules/semver/semver.browser.js.gz.
Solution is very simple - remove all .gz files from www subdirectory of your project and run build.
find www/lib -type f -name "*.gz" -exec rm -f {} \;

How to build phonegap offline from command line

I'm using phonegap 100% from the command line. If I build while connected to the internet it works
$ phonegap build android
[phonegap] executing 'cordova build android'...
[phonegap] completed 'cordova build android'
But if I disconnect from the internet I get errors
$ phonegap build android
[phonegap] executing 'cordova build android'...
cp: no such file or directory: /Users/gregg/src/hft-mobile-app/icon.png
Running command: /Users/gregg/src/hft-mobile-app/platforms/android/cordova/build
ANDROID_HOME=/Users/gregg/Downloads/android-sdk-macosx
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
Running: /Users/gregg/src/hft-mobile-app/platforms/android/gradlew cdvBuildDebug -b /Users/gregg/src/hft-mobile-app/platforms/android/build.gradle -Dorg.gradle.daemon=true
FAILURE:
Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:1.0.0+.
Required by:
:android:unspecified
>
Failed to list versions for com.android.tools.build:gradle.
>
Unable to load Maven meta-data from https://repo1.maven.org/maven2/com/android/tools/build/gradle/maven-metadata.xml.
>
Could not GET 'https://repo1.maven.org/maven2/com/android/tools/build/gradle/maven-metadata.xml'.
>
repo1.maven.org: nodename nor servname provided, or not known
* 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: 30.753 secs
/Users/gregg/src/hft-mobile-app/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Users/gregg/src/hft-mobile-app/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/gregg/src/hft-mobile-app/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/gregg/src/hft-mobile-app/platforms/android/cordova/build: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: /Users/gregg/src/hft-mobile-app/platforms/android/cordova/build: Command failed with exit code 1
at ChildProcess.whenDone (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
Why is the command line version phoning home? How do I get this to build 100% offline?
Note: I see this error as the 2nd line when trying to build offline
cp: no such file or directory: /Users/gregg/src/hft-mobile-app/icon.png
But as you can see that error does not occur online. Plus supposedly whatever that issue was was fixed according to this
I'm on OSX, I've got the Android SDK installed. I had no idea it was calling home. How do I get it to build offline?
This is what I have experienced till now. Ionic uses gradle for android build. It first time downloads all the dependencies from internet. So internet is most for first gradle build but it caches them and no internet is needed for further build.Since you are having problem why don't you globally update your cordova and ionic.
npm install -g cordova ionic

Cordova Android Build Failure

I am trying to get the basic Cordova v5.0 Android v4.0 project to build on Mac OS X Yosemite, but keep getting this error. Note: The same process builds fine on Cordova v4. I have uninstalled and reinstalled the Android SDK, Cordova, and even Gradle (but I don't think I need it). I've checked that my Path variable contains the correct paths to /tools and /platform_tools. But when I do the 'cordova build' or 'cordova build android' I always get the same error:
Could not create an instance of type
org.gradle.invocation.DefaultGradle_Decorated.
Further down it says:
You may not have the required environment or OS to build this project
What am I missing?
Here's the full text of what I'm doing:
my_acct$cordova create build_test com.example.build_test "BuildTest"
Creating a new cordova project.
my_acct$cd build_test
my_acct$cordova platform add android
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms/android
Package: com.example.build_test
Name: BuildTest
Activity: MainActivity
Android target: android-22
Copying template files...
Android project created with cordova-android#4.0.0
Discovered plugin "cordova-plugin-whitelist" in config.xml. Installing to the project
Fetching plugin "cordova-plugin-whitelist#1" via npm
npm http GET https://registry.npmjs.org/cordova-plugin-whitelist
npm http GET https://registry.npmjs.org/cordova-plugin-whitelist
npm http 304 https://registry.npmjs.org/cordova-plugin-whitelist
Installing "cordova-plugin-whitelist" for android
my_acct$cordova build
Running command: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build
ANDROID_HOME=/Users/my_acct/Documents/Development/android-sdk-macosx/sdk
JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Running: /Users/my_acct/Documents/Development/work/build_test/platforms/android/gradlew cdvBuildDebug -b /Users/my_acct/Documents/Development/work/build_test/platforms/android/build.gradle -Dorg.gradle.daemon=true
FAILURE: Build failed with an exception.
* What went wrong:
Could not create an instance of type org.gradle.invocation.DefaultGradle_Decorated.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
/Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Users/my_acct/Documents/Development/work/build_test/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/my_acct/Documents/Development/work/build_test/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build: Command failed with exit code 8
at ChildProcess.whenDone (/Users/my_acct/.node/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:766:16)
at Process.ChildProcess._handle.onexit (child_process.js:833:5)
If I change to use java 1.7 or 1.8, the error changes to:
A problem occurred configuring root project 'android'.
Could not resolve all dependencies for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:1.0.0+.
Required by:
:android:unspecified
org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
Here's the full results for using java 1.7 or 1.8:
my_acct$cordova build
Running command: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build
ANDROID_HOME=/Users/my_acct/Documents/Development/android-sdk-macosx/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
Running: /Users/my_acct/Documents/Development/work/build_test/platforms/android/gradlew cdvBuildDebug -b /Users/my_acct/Documents/Development/work/build_test/platforms/android/build.gradle -Dorg.gradle.daemon=true
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:1.0.0+.
Required by:
:android:unspecified
> org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
* 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: 4.859 secs
/Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Users/my_acct/Documents/Development/work/build_test/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/my_acct/Documents/Development/work/build_test/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build: Command failed with exit code 8
at ChildProcess.whenDone (/Users/my_acct/.node/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:766:16)
at Process.ChildProcess._handle.onexit (child_process.js:833:5)
I figured it out. I found old, conflicting .jar files in ~/Library/Java/Extensions. Blew away the entire ~/Library/Java directory. Cordova (and Android Studio) runs great now.
The other way how this problem can be resolved is by changing the repository from
mavenCentral()
to
maven{
url 'https://repo1.maven.org/maven2'
}
in both platforms/android/build.gradle and platforms/android/CordovaLib/build.gradle

Categories

Resources