Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to read PNG signature: file does not start with PNG signature

It's likely a JPG renamed to a PNG file, not an actual PNG file
The problem could be because of the wrong extension of images.

In my case, the file was a JPEG image but it was saved as PNG not converted to. In this situation change extension to the real one and convert to PNG then retry.

For instance, you have ic_logo.png but it's actually a JPG image.
You should rename it back to ic_logo.jpg and use something like Photoshop to convert the image to PNG format.


Steps

  1. In build.gradle

    aaptOptions { cruncherEnabled = false }

  2. Delete content inside C:\Users\.gradle\caches

  3. Restart Android Studio

android {
    buildTypes {
        release {
            crunchPngs false // or true
        }
    }
}







 buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            crunchPngs false // or true

            lintOptions {
                checkReleaseBuilds false
                abortOnError false
            }
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

Creating the .apk of an application all the resources are analyzed, if some resource has an incorrect format or is corrup you will get the message:

.png failed to read PNG signature: file does not start with PNG signature

enter image description here

Be sure to have the correct resources, you can check it by opening your file.


This occurs due to the incorrect extension given to the image. For example, the image is jpg and the extension given is png.

Solutions:

  1. Add { cruncherEnabled = false } in build.gradle
  2. Convert the image into png rather than just changing the extension.