读取 PNG 签名失败:文件不以 PNG 签名开头

时间:2023-02-13
本文介绍了读取 PNG 签名失败:文件不以 PNG 签名开头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Gradle 构建失败并出现此错误:

Gradle build failing with this error:

Error:C:UsersRoman.gradlecaches	ransforms-1files-1.1appcompat-v7-26.0.2.aarab547c3f1b8061ef9426f524a823a15
esdrawable-xhdpi-v4abc_btn_switch_to_on_mtrl_00001.9.png failed to read PNG signature: file does not start with PNG signature

Error:java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.internal.aapt.AaptException: AAPT2 compile failed:
Error:Execution failed for task ':app:mergeDebugResources'.
Error: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.internal.aapt.AaptException: AAPT2 compile failed:
aapt2 compile --legacy -o C:devworkspaceandroid2MatrixCalculatorappuildintermediates
esmergeddebug C:UsersRoman.gradlecaches	ransforms-1files-1.1appcompat-v7-26.0.2.aarab547c3f1b8061ef9426f524a823a15
esdrawable-xhdpi-v4abc_btn_switch_to_on_mtrl_00001.9.png
Issues:
 - ERROR: C:UsersRoman.gradlecaches	ransforms-1files-1.1appcompat-v7-26.0.2.aarab547c3f1b8061ef9426f524a823a15
esdrawable-xhdpi-v4abc_btn_switch_to_on_mtrl_00001.9.png failed to read PNG signature: file does not start with PNG signature

我尝试解决此问题的一些基本方法:

Some basic things i've tried to solve this issue:

  1. 使缓存失效/重启
  2. 删除 gradle 文件夹

推荐答案

很可能是 JPG 重命名为 PNG 文件,而不是实际的 PNG 文件
问题可能是由于图像的错误扩展名造成的.

就我而言,该文件是 JPEG 图像,但它保存为 PNG 未转换为.在这种情况下,将扩展名更改为真实的扩展名并转换为 PNG,然后重试.

It's likely a JPG renamed to a PNG file, not an actual PNG file
The problem could be because of the wrong extension of images.

In my case, the file was a JPEG image but it was saved as PNG not converted to. In this situation change extension to the real one and convert to PNG then retry.

例如,您有 ic_logo.png,但它实际上是 JPG 图片.
您应该将其重命名为 ic_logo.jpg 并使用 Photoshop 之类的工具将图像转换为 PNG 格式.

For instance, you have ic_logo.png but it's actually a JPG image.
You should rename it back to ic_logo.jpg and use something like Photoshop to convert the image to PNG format.

这篇关于读取 PNG 签名失败:文件不以 PNG 签名开头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!