Ionic android build problem

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: GitHub - appfeel/admob-google-cordova: AdMob ads Cordova/Phonegap/Intel XDK plugin for Android iPhone with latest SDK's

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

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

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

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

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.

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

3 Likes

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.

1 Like

thanks, i solved my problem by your solution.

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

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

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

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