Error while generating apk for android platform


#1

Hi all,

I’m facing a problem during building my project to release android APK file. Here is the command and error messages. I’m using ionic 3.7.0.

Yes-MacBook-Pro:----- YeYint$ sudo ionic cordova build --release android
Password:
Running app-scripts build: --build --iscordovaserve --nobrowser

[23:10:59] build dev started …
[23:10:59] clean started …
[23:11:00] clean finished in 84 ms
[23:11:00] copy started …
[23:11:00] transpile started …
[23:11:10] transpile finished in 10.60 s
[23:11:10] preprocess started …
[23:11:10] deeplinks started …
[23:11:10] deeplinks finished in 135 ms
[23:11:10] preprocess finished in 136 ms
[23:11:10] webpack started …
[23:11:12] copy finished in 12.13 s
[23:11:23] webpack finished in 12.61 s
[23:11:23] sass started …
[23:11:26] sass finished in 2.75 s
[23:11:26] postprocess started …
[23:11:26] postprocess finished in 53 ms
[23:11:26] lint started …
[23:11:26] build dev finished in 26.50 s

ionic cordova prepare
cordova prepare
:heavy_check_mark: Running command - done!

cordova build android --release
:heavy_multiplication_x: Running command - failed!

[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova build android --release (exit code 1):

    ANDROID_HOME=/Users/YeYint/Library/Android/sdk
    JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home
    Subproject Path: CordovaLib
    The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use
    Task.doLast(Action) instead.
    at build_41twm1hm5i9x95vtmnjvuijgj.run(/Users/YeYint/iRoute/platforms/android/build.gradle:137)
    The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0.
    Incremental java compilation is an incubating feature.
    The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please
    use TaskInputs.file(Object).skipWhenEmpty() instead.
    :preBuild UP-TO-DATE
    :preReleaseBuild UP-TO-DATE
    :checkReleaseManifest
    :CordovaLib:preBuild UP-TO-DATE
    :CordovaLib:preReleaseBuild UP-TO-DATE
    :CordovaLib:checkReleaseManifest
    :CordovaLib:prepareReleaseDependencies
    :CordovaLib:compileReleaseAidl
    :CordovaLib:compileReleaseNdk UP-TO-DATE
    :CordovaLib:compileLint UP-TO-DATE
    :CordovaLib:copyReleaseLint UP-TO-DATE
    :CordovaLib:mergeReleaseShaders
    :CordovaLib:compileReleaseShaders
    :CordovaLib:generateReleaseAssets
    :CordovaLib:mergeReleaseAssets
    :CordovaLib:mergeReleaseProguardFiles
    :CordovaLib:packageReleaseRenderscript UP-TO-DATE
    :CordovaLib:compileReleaseRenderscript
    :CordovaLib:generateReleaseResValues
    :CordovaLib:generateReleaseResources
    :CordovaLib:packageReleaseResources
    :CordovaLib:processReleaseManifest
    :CordovaLib:generateReleaseBuildConfig
    :CordovaLib:processReleaseResources
    :CordovaLib:generateReleaseSources
    :CordovaLib:incrementalReleaseJavaCompilationSafeguard
    :CordovaLib:compileReleaseJavaWithJavac
    :CordovaLib:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution,
    etc.).
    Note: Some input files use or override a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    :CordovaLib:processReleaseJavaRes UP-TO-DATE
    :CordovaLib:transformResourcesWithMergeJavaResForRelease
    :CordovaLib:transformClassesAndResourcesWithSyncLibJarsForRelease
    :CordovaLib:mergeReleaseJniLibFolders
    :CordovaLib:transformNative_libsWithMergeJniLibsForRelease
    :CordovaLib:transformNative_libsWithSyncJniLibsForRelease
    :CordovaLib:bundleRelease
    :prepareOrgApacheCordovaCordovaLib623ReleaseLibrary
    :prepareReleaseDependencies
    :compileReleaseAidl
    :compileReleaseRenderscript
    :generateReleaseBuildConfig
    :generateReleaseResValues
    :generateReleaseResources
    :mergeReleaseResources
    AAPT: libpng error: Read Error
    AAPT err(Facade for 2091062548) : No Delegate set : lost message:libpng error: Read Error
    AAPT: libpng error: Read Error
    AAPT: libpng error: Read Error
    AAPT: libpng error: Read Error
    AAPT: libpng error: Read Error
    AAPT: libpng error: Read Error
    AAPT: libpng error: Read Error
    AAPT: libpng error: Read Error
    AAPT: libpng error: Read Error
    AAPT: libpng error: Read Error
    AAPT: libpng error: Read Error
    Error: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:
    :mergeReleaseResources FAILED
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':mergeReleaseResources'.
    > Error: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:
    
    * 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: 9.238 secs
    Error: /Users/YeYint/iRoute/platforms/android/gradlew: Command failed with exit code 1 Error output:
    Note: Some input files use or override a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    AAPT err(Facade for 2091062548) : No Delegate set : lost message:libpng error: Read Error
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':mergeReleaseResources'.
    > Error: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

#2

Or temporary solution is to place the code below in the module build.gradle:

android {
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
}


#3

Thanks heap for the kind help. I can now generate apk by adding your temporary solution. APK is now generated but the apk is unable to install. It was showing “Application is not installed” message when I try to install on my devices.

Please advise. Thanks!


#4

libpng, is this error maybe caused by invalidsplash or icon files?


#5

Thanks a lot!!! Works from me