Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
GunaShekar02 opened this issue Jul 14, 2019 · 6 comments
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.

Comments

@GunaShekar02
Copy link

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.
@react-native-bot react-native-bot added the Platform: Android Android applications. label Jul 14, 2019
@RobinCsl
Copy link

RobinCsl commented Jul 14, 2019

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!

@digistaal
Copy link

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!

@muganwas
Copy link

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?

@GunaShekar02
Copy link
Author

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

@KaoPengHsiang
Copy link

@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 : )

@Ankit2388
Copy link

Ankit2388 commented Jul 23, 2020

this is work for me
thank @KaoPengHsiang

@facebook facebook locked as resolved and limited conversation to collaborators Oct 8, 2021
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

7 participants