問題描述
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:
- 使緩存失效/重啟
- 刪除 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模板網!