2

Here is the error that keeps coming up on the event log:

Generate Signed APK: Errors while building APK. You can find the errors in the 'Messages' view

And this in the messages:

Android resource compilation failed Output:

C:\Users\me\AndroidStudioProjects\SimpleCalculator2\app\src\main\res\mipmap-xxhdpi\ic_launcher.png: error: failed to read PNG signature: file does not start with PNG signature.

Command:

 C:\Users\me\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971- windows.jar\6c29a9fd1a7f2d4d5ddcbb0cbfa348c6\aapt2-3.2.0-4818971-windows\aapt2.exe compile --legacy\-o\

C:\Users\me\AndroidStudioProjects\SimpleCalculator2\app\build\intermediates\res\merged\release \

C:\Users\me\AndroidStudioProjects\SimpleCalculator2\app\src\main\res\mipmap-xxhdpi\ic_launcher.png

Daemon: AAPT2 aapt2-3.2.0-4818971-windows Daemon #0

Tanveer Munir
  • 1,956
  • 1
  • 12
  • 27
wizsab
  • 45
  • 2
  • 8
  • 1
    https://stackoverflow.com/questions/46177560/failed-to-read-png-signature-file-does-not-start-with-png-signature – Amr Eldessouki Jan 24 '19 at 02:40
  • Possible duplicate of [Failed to read PNG signature: file does not start with PNG signature](https://stackoverflow.com/questions/46177560/failed-to-read-png-signature-file-does-not-start-with-png-signature) – ישו אוהב אותך Jan 24 '19 at 14:40

3 Answers3

6

Just paste this in your build.gradle file

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

This happens when you either rename an image or when you just cut and paste an image anywhere in the app folders, At Build time the compiler will complain about this.

Barungi Stephen
  • 759
  • 8
  • 13
3

Seeing your logs and as Praveen suggested:

I feel some PNG files are corrupted and were not parsed. Sometimes the images have an extension but are not real PNG.

You can check if the images in your project are real PNGs with the below command :

find . -type f -name "*.png" | xargs -L 1 -I{} file  -I {} | grep -v 'image/png; charset=binary$'

After getting the list use this site to convert them to PNG.

Aarth Tandel
  • 1,001
  • 12
  • 32
0

Cause: It might be because you Stored the Image in another format with a .png extension. Solution: Don't just rename the file extension Convert your image file to .png format

Praveen
  • 93
  • 1
  • 7