Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio AAPT err: libpng error: Not a PNG file

I have search all the possible available solution but still i am facing same issue with unclear error for me.

Now the complete error is-

AAPT err(Facade for 370671127): libpng error: Not a PNG file Error:Execution failed for task ':app:mergeDebugResources'.

Some file crunching failed, see logs for details

Now from this line libpng error: Not a PNG file actual i am not getting where is the problem exist either in my any image files or anything else except this.

1- Before posting this issues i have changed my all the images existing in the diff-2 folders in required PNG formates as I see as solution in other post.

Note- Its working fine on eclipse now I am importing this in Android Studio.

Since during project build only single(above) error is shown so I guess there is not should be any other issue. I have spend more time to resolve this issues so all the suggestions are welcomes for me.

like image 277
admaurya Avatar asked Dec 11 '15 07:12

admaurya


2 Answers

The problem is in your png files. Probably you images were optimized by some png optimization tools. Android tools use AAPT tool to optimize images during building your project. The reason for this problem is that AAPT tool doesn't know that you preprocessed the image.

To get around this in your application you need to specify the option in gradle

  aaptOptions{
    cruncherEnabled = false
}

This is disable AAPT optimization for all of your png files.

Similar question was asked here.

like image 167
Volodymyr Avatar answered Nov 11 '22 10:11

Volodymyr


Although there can be various reasons for this error , i.e Can't resolve symbol R

But In particular, If the problem is saying Not a PNG file

My Case

For me ,it was a jpeg file that I had saved with extension .png which was the root cause

Solution

remove that jpeg image from your res/drawable folder

Note

renaming a jpeg to png doesn't mean it is a png in android studio... so get rid of that jpeg image

rebuild..

voila.. it works

hope it helps :)

like image 5
eRaisedToX Avatar answered Nov 11 '22 12:11

eRaisedToX