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

admaurya picture admaurya · Dec 11, 2015 · Viewed 18.1k times · Source

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.

Answer

Volodymyr picture Volodymyr · May 19, 2016

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.