-1

my application is compiled and working fine in debug mode. But in release mode it gives error when compiling screen image as below

Configuration on demand is an incubating feature. NDK is missing a "platforms" directory. If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to C:\Users\pel\AppData\Local\Android\Sdk\ndk-bundle. If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

Could not find google-services.json while looking in [src/nullnull/debug, src/debug/nullnull, src/nullnull, src/debug, src/nullnullDebug] registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) Could not find google-services.json while looking in [src/nullnull/release, src/release/nullnull, src/nullnull, src/release, src/nullnullRelease] registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) :app:preBuild UP-TO-DATE :app:preReleaseBuild UP-TO-DATE :app:compileReleaseAidl UP-TO-DATE :app:compileReleaseRenderscript UP-TO-DATE :app:checkReleaseManifest UP-TO-DATE :app:generateReleaseBuildConfig UP-TO-DATE :app:prepareLintJar UP-TO-DATE :app:mainApkListPersistenceRelease UP-TO-DATE :app:generateReleaseResValues UP-TO-DATE :app:generateReleaseResources UP-TO-DATE :app:processReleaseGoogleServices Parsing json file: D:\SEDAT\PROJELER\ANDROIDPROJELER\egiticioyunlar\app\google-services.json :app:mergeReleaseResources D:\pel\PROJELER\ANDROIDPROJELER\egiticioyunlar\app\src\main\res\drawable\ic_stat_ic_notification.png: error: failed to read PNG signature: file does not start with PNG signature. Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details :app:mergeReleaseResources FAILED

tedris
  • 1,118
  • 2
  • 7
  • 11

2 Answers2

0

tldr:
The PNG file at path "D:\pel\PROJELER\ANDROIDPROJELER\egiticioyunlar\ app\src\main\res\drawable\ic_stat_ic_notification.png" is corrupted. Make sure you use valid PNG files.

The why:
The difference between the debug and release modes comes from different needs for each build. The debug build needs to be faster, as they are executed very often. The release build needs to produce optimised (smaller) APKs, since this is the product that will be delivered to the user.

This is why PNG crunching (compressing the image files if possible) is disabled for debug builds, but enabled for the release builds. PNG crunching looks at the contents of the file thoroughly and therefore if there's something wrong with the file, an error will be raised during the release build.

During the debug build PNG crunching is disabled. The PNG is still compiled (processed), but not optimised and therefore not everything can be caught as often as in the release build.

If you want, you can enable PNG crunching for debug builds as well, but I would not recommend it as it greatly impacts the build time (up to 30% slower resource processing). Similarly, you can disable PNG crunching for release builds, but that can in turn make the APK much, much bigger, and I highly discourage that too.

android {
    buildTypes {
        release {
            // Disables PNG crunching for the release build type. Don't do this.
            crunchPngs false
        }
        debug {
            // Enabled PNG crunching for the debug build type. Don't do this.
            crunchPngs true
        }
    }
}
Izabela Orlowska
  • 7,431
  • 2
  • 20
  • 33
0

I've created a binary file called "debug" and "release" in the main directory. I put the "google-services.json" file into it and it was compiled without error.

tedris
  • 1,118
  • 2
  • 7
  • 11