无法读取 PNG 签名:文件不是以 PNG 签名开头 [英] Failed to read PNG signature: file does not start with PNG signature

查看:22
本文介绍了无法读取 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 签名开头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆