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

Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

Error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> Multiple task action failures occurred:
   > A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
      > Android resource compilation failed
        ERROR:C:\Users\dharm\AndroidStudioProjects\webviewhospital\android\app\src\main\res\mipmap-mdpi\launcher_icon.png: AAPT: error: failed 
to read PNG signature: file does not start with PNG signature.

        ERROR:C:\Users\dharm\AndroidStudioProjects\webviewhospital\android\app\src\main\res\mipmap-mdpi\launcher_icon.png: AAPT: error: file failed to compile.

   > A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
      > Android resource compilation failed
        ERROR:C:\Users\dharm\AndroidStudioProjects\webviewhospital\android\app\src\main\res\mipmap-hdpi\launcher_icon.png: AAPT: error: failed 
to read PNG signature: file does not start with PNG signature.

        ERROR:C:\Users\dharm\AndroidStudioProjects\webviewhospital\android\app\src\main\res\mipmap-hdpi\launcher_icon.png: AAPT: error: file failed to compile.

   > A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
      > Android resource compilation failed
        ERROR:C:\Users\dharm\AndroidStudioProjects\webviewhospital\android\app\src\main\res\mipmap-xhdpi\launcher_icon.png: AAPT: error: failed to read PNG signature: file does not start with PNG signature.

        ERROR:C:\Users\dharm\AndroidStudioProjects\webviewhospital\android\app\src\main\res\mipmap-xhdpi\launcher_icon.png: AAPT: error: file failed to compile.

   > A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
      > Android resource compilation failed
        ERROR:C:\Users\dharm\AndroidStudioProjects\webviewhospital\android\app\src\main\res\mipmap-xxhdpi\launcher_icon.png: AAPT: error: failed to read PNG signature: file does not start with PNG signature.

        ERROR:C:\Users\dharm\AndroidStudioProjects\webviewhospital\android\app\src\main\res\mipmap-xxhdpi\launcher_icon.png: AAPT: error: file 
failed to compile.

   > A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
      > Android resource compilation failed
        ERROR:C:\Users\dharm\AndroidStudioProjects\webviewhospital\android\app\src\main\res\mipmap-xxxhdpi\launcher_icon.png: AAPT: error: failed to read PNG signature: file does not start with PNG signature.

        ERROR:C:\Users\dharm\AndroidStudioProjects\webviewhospital\android\app\src\main\res\mipmap-xxxhdpi\launcher_icon.png: AAPT: error: file failed to compile.


* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Solution:

You might have used a JPEG file or some other image file format.

Use PNG images to solve the error.

The drawable directory can only have png type of images.

If you are using an online platform to generate App Icon(launcher_icon), then use PNG Format or First convert JPEG to PNG and then used APP ICON GENERATOR

1

In my case also there was a jpg file instead of png, so I changed my extension and solve my problem.

Open [Root_project]/app/build.gradle and add following lines.

release {
          ...

            crunchPngs false // or true

            lintOptions {
                checkReleaseBuilds false
                abortOnError false
            }

          ...
}

I have same error for slow i do some steps:

  1. open abc_btn_switch_to_on_mtrl_00001.9.png (Image)file in paint
  2. now select png and save as and re-save in Drawable and overwrite the old images and it works
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x