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

醉酒当歌 提交于 2019-11-28 20:34:57

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.

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 :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!