Ionic android build problem


#1

android build error
Anyone guess what is the problem?
error log
`Prosenjits-Mini:ionicwordpress prosenjitmanna$ ionic build android
Running command: /Users/prosenjitmanna/dev/ionicwordpress/hooks/after_prepare/010_add_platform_class.js /Users/prosenjitmanna/dev/ionicwordpress
add to body class: platform-android

*********** Monetize your app with AdMob ads. Now available with this cordova plugin:
*********** cordova plugin add com.admob.google
*********** Docs: https://github.com/appfeel/admob-google-cordova

`Running command: /Users/prosenjitmanna/dev/ionicwordpress/platforms/android/cordova/build
ANDROID_HOME=/users/prosenjitmanna/dev/devtools/android
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home
Running: /Users/prosenjitmanna/dev/ionicwordpress/platforms/android/gradlew cdvBuildDebug -b /Users/prosenjitmanna/dev/ionicwordpress/platforms/android/build.gradle -Dorg.gradle.daemon=true
:preBuild
:compileDebugNdk UP-TO-DATE
:preDebugBuild
:checkDebugManifest
:CordovaLib:compileLint
:CordovaLib:copyDebugLint UP-TO-DATE
:CordovaLib:mergeDebugProguardFiles UP-TO-DATE
:CordovaLib:preBuild
:CordovaLib:preDebugBuild
:CordovaLib:checkDebugManifest
:CordovaLib:prepareDebugDependencies
:CordovaLib:compileDebugAidl UP-TO-DATE
:CordovaLib:compileDebugRenderscript UP-TO-DATE
:CordovaLib:generateDebugBuildConfig UP-TO-DATE
:CordovaLib:generateDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugAssets UP-TO-DATE
:CordovaLib:generateDebugResValues UP-TO-DATE
:CordovaLib:generateDebugResources UP-TO-DATE
:CordovaLib:packageDebugResources UP-TO-DATE
:CordovaLib:processDebugManifest UP-TO-DATE
:CordovaLib:processDebugResources UP-TO-DATE
:CordovaLib:generateDebugSources UP-TO-DATE
:CordovaLib:compileDebugJava UP-TO-DATE
:CordovaLib:processDebugJavaRes UP-TO-DATE
:CordovaLib:packageDebugJar UP-TO-DATE
:CordovaLib:compileDebugNdk UP-TO-DATE
:CordovaLib:packageDebugJniLibs UP-TO-DATE
:CordovaLib:packageDebugLocalJar UP-TO-DATE
:CordovaLib:packageDebugRenderscript UP-TO-DATE
:CordovaLib:bundleDebug UP-TO-DATE
:com.google.play.services:ionicwordpress352140-google-play-services_lib:compileLint
:com.google.play.services:ionicwordpress352140-google-play-services_lib:copyDebugLint UP-TO-DATE
:com.google.play.services:ionicwordpress352140-google-play-services_lib:mergeDebugProguardFiles UP-TO-DATE
:com.google.play.services:ionicwordpress352140-google-play-services_lib:preBuild
:com.google.play.services:ionicwordpress352140-google-play-services_lib:preDebugBuild
:com.google.play.services:ionicwordpress352140-google-play-services_lib:checkDebugManifest
:com.google.play.services:ionicwordpress352140-google-play-services_lib:preDebugTestBuild
:com.google.play.services:ionicwordpress352140-google-play-services_lib:prepareAndroidCordovaLibUnspecifiedDebugLibrary UP-TO-DATE
:com.google.play.services:ionicwordpress352140-google-play-services_lib:prepareDebugDependencies
:com.google.play.services:ionicwordpress352140-google-play-services_lib:compileDebugAidl UP-TO-DATE
:com.google.play.services:ionicwordpress352140-google-play-services_lib:compileDebugRenderscript UP-TO-DATE
:com.google.play.services:ionicwordpress352140-google-play-services_lib:generateDebugBuildConfig UP-TO-DATE
:com.google.play.services:ionicwordpress352140-google-play-services_lib:generateDebugAssets UP-TO-DATE
:com.google.play.services:ionicwordpress352140-google-play-services_lib:mergeDebugAssets UP-TO-DATE
:com.google.play.services:ionicwordpress352140-google-play-services_lib:generateDebugResValues UP-TO-DATE
:com.google.play.services:ionicwordpress352140-google-play-services_lib:generateDebugResources UP-TO-DATE
:com.google.play.services:ionicwordpress352140-google-play-services_lib:mergeDebugResources UP-TO-DATE
:com.google.play.services:ionicwordpress352140-google-play-services_lib:processDebugManifest UP-TO-DATE
:com.google.play.services:ionicwordpress352140-google-play-services_lib:processDebugResources UP-TO-DATE
:com.google.play.services:ionicwordpress352140-google-play-services_lib:generateDebugSources UP-TO-DATE
:com.google.play.services:ionicwordpress352140-google-play-services_lib:compileDebugJava UP-TO-DATE
:com.google.play.services:ionicwordpress352140-google-play-services_lib:processDebugJavaRes UP-TO-DATE
:com.google.play.services:ionicwordpress352140-google-play-services_lib:packageDebugJar UP-TO-DATE
:com.google.play.services:ionicwordpress352140-google-play-services_lib:compileDebugNdk UP-TO-DATE
:com.google.play.services:ionicwordpress352140-google-play-services_lib:packageDebugJniLibs UP-TO-DATE
:com.google.play.services:ionicwordpress352140-google-play-services_lib:packageDebugLocalJar UP-TO-DATE
:com.google.play.services:ionicwordpress352140-google-play-services_lib:packageDebugRenderscript UP-TO-DATE
:com.google.play.services:ionicwordpress352140-google-play-services_lib:packageDebugResources UP-TO-DATE
:com.google.play.services:ionicwordpress352140-google-play-services_lib:bundleDebug UP-TO-DATE
:prepareAndroidComGooglePlayServicesIonicwordpress352140GooglePlayServices_libUnspecifiedDebugLibrary UP-TO-DATE
:prepareAndroidCordovaLibUnspecifiedDebugLibrary UP-TO-DATE
:prepareDebugDependencies
:compileDebugAidl UP-TO-DATE
:compileDebugRenderscript UP-TO-DATE
:generateDebugBuildConfig UP-TO-DATE
:generateDebugAssets UP-TO-DATE
:mergeDebugAssets UP-TO-DATE
:generateDebugResValues UP-TO-DATE
:generateDebugResources UP-TO-DATE
:mergeDebugResourceslibpng error: Read Error

Error: Failed to run command:
/users/prosenjitmanna/dev/devtools/android/build-tools/22.0.1/aapt s -i /Users/prosenjitmanna/dev/ionicwordpress/platforms/android/res/drawable-port-xhdpi/screen.png -o /Users/prosenjitmanna/dev/ionicwordpress/platforms/android/build/intermediates/res/debug/drawable-port-xhdpi-v4/screen.png
Error Code:
42
Output:
libpng error: Read Error

:mergeDebugResources FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:mergeDebugResources’.

Error: Failed to run command:
/users/prosenjitmanna/dev/devtools/android/build-tools/22.0.1/aapt s -i /Users/prosenjitmanna/dev/ionicwordpress/platforms/android/res/drawable-port-xhdpi/screen.png -o /Users/prosenjitmanna/dev/ionicwordpress/platforms/android/build/intermediates/res/debug/drawable-port-xhdpi-v4/screen.png
Error Code:
42
Output:
libpng error: Read Error

  • 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.316 secs

/Users/prosenjitmanna/dev/ionicwordpress/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Users/prosenjitmanna/dev/ionicwordpress/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/prosenjitmanna/dev/ionicwordpress/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/prosenjitmanna/dev/ionicwordpress/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/prosenjitmanna/dev/ionicwordpress/platforms/android/cordova/build: Command failed with exit code 1
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:134: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)`


#2

Not the same error message, but very similar (mergeDebugResources vs mergeDebugAssets), you might find something usefull there:


#3

Already tried to remove the android platform and add it again?


#4

I try to remove and add again but problem not solved.
Also I have only one SDK


#5

Did you ever fix this problem? I’m running into the same problem. Seems that /drawable-port-xhdpi/screen.png is not generated during the build proces. Therefore the build error’s once trying to read it. It seems the size is however properly generated by ionic in resource/android so I don’t understand why only this sizes is not correctly copied during the build process.


[SOLVED] Execution failed for task ‘:mergeDebugResources’
#6

My problem was solved. When I removed platform and generated resources and restore state by ionic state restore and generate again resources by ionic resources


#7

I solved this problem.

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.


#8

thanks, i solved my problem by your solution.

actually, we can run ‘ionic resource --icon’ or ‘ionic resource --splash’ to regenerate these files.


#9

while Building i am getting the following error…

Please any one give me a solution for this problem

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 ‘C:\Program Files (x86)\Android\android-sdk\build-tools\23.0.3\aapt.exe’’ finished with non-zero exit value 1

BUILD FAILED


#10

This is how i solved my Error

  1. I wanted to set splash screen
  2. and i had SPLASH.jpg image
  3. and i just changed extension to splash.png
  4. and it started giving error
  5. then i i kept normal png which worked fine
  6. then i added ALPHA CHANNEL with photoshop to image SPLASH.jpg and saved as SPLASH.png
  7. then error was

so moral of the story is don’t just change file extension blindly to make it work … if you want to change extension use photoshop or use any online website image format converter


Build an cordova release
#11

thanks a lot for your comment! been on this for hours