Skip to content

Execution failed for task ':app:mergeReleaseResources'. after exp build:android #25641

Closed

Description

@GunaShekar02

React Native version: https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz

Describe what you expected to happen:
The build is successful when I do not change the default icon in app.json but the build fails with the following error message when I change the icon. I have checked the icon, it is definitely a png file.

> Task :app:mergeReleaseResources FAILED
17 actionable tasks: 17 executed
[stderr] FAILURE: Build failed with an exception.
[stderr] * What went wrong:
[stderr] Execution failed for task ':app:mergeReleaseResources'.
[stderr] > java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
[stderr]   /app/turtle/workingdir/android/sdk33/android-shell-app/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: error: failed to read PNG signature: file does not start with PNG signature.

Activity

  1. RobinCsl commented on Jul 14, 2019

    @RobinCsl

    Hi @GunaShekar02,

    It looks like you're using Expo to build your application, so I am not sure this is the best repository to get help.

    It looks like this error message was already reported on Expo's forum and the OP seems to have solved their issue: https://forums.expo.io/t/failed-to-read-png-signature-file-does-not-start-with-png-signature/23806

    Hope that helps!

  2. digistaal commented on Sep 26, 2019

    @digistaal

    For feature googlers: in my case i just upgraded to RN 0.60, which places an empty ic_launcher_round.png file in my app/src/main/res/mipmax-xxx folders. Place a real png file there and the error should be gone!

  3. muganwas commented on Mar 11, 2020

    @muganwas

    For feature googlers: in my case i just upgraded to RN 0.60, which places an empty ic_launcher_round.png file in my app/src/main/res/mipmax-xxx folders. Place a real png file there and the error should be gone!

    Happened to me and I'm us RN 0.60.4, any better answers?

  4. GunaShekar02 commented on Mar 11, 2020

    @GunaShekar02
    Author

    Using "expo-cli build:android -t apk" instead of "exp build:android" worked for me at that point.

  5. KaoPengHsiang commented on Mar 17, 2020

    @KaoPengHsiang

    @muganwas Hi~~
    Maybe try this I used to debug release build in old version, but still looks work for me now(I'm trying to update to 0.61.5).
    I can't found the source where I found it, just copy from my old code and add in similar way.
    My version now: RN 0.61.5
    Change or add some code from here:
    \node_modules\react-native\react.gradle

    if (enableHermes) {
                    doLast {
                        def hermesFlags;
                        def hbcTempFile = file("${jsBundleFile}.hbc")
                        exec {
                            if (targetName.toLowerCase().contains("release")) {
                                // Can't use ?: since that will also substitute valid empty lists
                                hermesFlags = config.hermesFlagsRelease
                                if (hermesFlags == null) hermesFlags = ["-O", "-output-source-map"]
                            } else {
                                hermesFlags = config.hermesFlagsDebug
                                if (hermesFlags == null) hermesFlags = []
                            }
                            
                            if (Os.isFamily(Os.FAMILY_WINDOWS)) {
                                commandLine("cmd", "/c", getHermesCommand(), "-emit-binary", "-out", hbcTempFile, jsBundleFile, *hermesFlags)
                            } else {
                                commandLine(getHermesCommand(), "-emit-binary", "-out", hbcTempFile, jsBundleFile, *hermesFlags)
                            }
                        }
                        ant.move(
                            file: hbcTempFile,
                            toFile: jsBundleFile
                        );
                        if (hermesFlags.contains("-output-source-map")) {
                            ant.move(
                                // Hermes will generate a source map with this exact name
                                file: "${jsBundleFile}.hbc.map",
                                tofile: jsCompilerSourceMapFile
                            );
                            exec {
                                // TODO: set task dependencies for caching
    
                                // Set up the call to the compose-source-maps script
                                workingDir(reactRoot)
                                if (Os.isFamily(Os.FAMILY_WINDOWS)) {
                                    commandLine("cmd", "/c", *nodeExecutableAndArgs, composeSourceMapsPath, jsPackagerSourceMapFile, jsCompilerSourceMapFile, "-o", jsOutputSourceMapFile)
                                } else {
                                    commandLine(*nodeExecutableAndArgs, composeSourceMapsPath, jsPackagerSourceMapFile, jsCompilerSourceMapFile, "-o", jsOutputSourceMapFile)
                                }
                            }
                        }
                    }
    //////////////////////////////////// From  Here and in else put again with dolast
    //////////////////////////////////// If your version doesn't have code above, just add code doLast
    //////////////////////////////////// in else, put doLast after do first
                    def moveFunc = { resSuffix ->
                        File originalDir = file("${resourcesDir}/drawable-${resSuffix}");
                        // File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");
    
                        if (originalDir.exists()) {
                            File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");
                            ant.move(file: originalDir, tofile: destDir);
                        }
                    }
                    moveFunc.curry("ldpi").call()
                    moveFunc.curry("mdpi").call()
                    moveFunc.curry("hdpi").call()
                    moveFunc.curry("xhdpi").call()
                    moveFunc.curry("xxhdpi").call()
                    moveFunc.curry("xxxhdpi").call()
    
                }else{
                        doLast {
                        def moveFunc = { resSuffix ->
                            File originalDir = file("${resourcesDir}/drawable-${resSuffix}");
                            // File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");
    
                            if (originalDir.exists()) {
                                File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");
                                ant.move(file: originalDir, tofile: destDir);
                            }
                        }
                        moveFunc.curry("ldpi").call()
                        moveFunc.curry("mdpi").call()
                        moveFunc.curry("hdpi").call()
                        moveFunc.curry("xhdpi").call()
                        moveFunc.curry("xxhdpi").call()
                        moveFunc.curry("xxxhdpi").call()
                        
                    }
                }

    Hope this can help someone : )

  6. Ankit2388 commented on Jul 23, 2020

    @Ankit2388

    this is work for me
    thank @KaoPengHsiang

  7. locked as resolved and limited conversation to collaborators on Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions