Skip to content

Instantly share code, notes, and snippets.

@luk0y
Created December 9, 2023 10:51
Show Gist options
  • Save luk0y/5bb9aa66015c00fe605e7fdddd06abd4 to your computer and use it in GitHub Desktop.
Save luk0y/5bb9aa66015c00fe605e7fdddd06abd4 to your computer and use it in GitHub Desktop.
failed to read PNG signature: file does not start with PNG signature. - apktool
Have you ever gone through this error while building apk using apktool?
W: /home/nnnn/Desktop/Android/com.package/res/drawable-hdpi/arrow_t_l.png: error: failed to read PNG signature: file does not start with PNG signature.
W: /home/nnnn/Desktop/Android/com.package/res/drawable-hdpi/arrow_t_l.png: error: file failed to compile.
W: /home/nnnn/Desktop/Android/com.package/res/drawable-hdpi/arrow_t_r.png: error: failed to read PNG signature: file does not start with PNG signature.
W: /home/nnnn/Desktop/Android/com.package/res/drawable-hdpi/arrow_t_r.png: error: file failed to compile.
brut.androlib.exceptions.AndrolibException: brut.common.BrutException: could not exec (exit code = 1):
Here's the solution:
when I use tried to check if the files are valid png's using this command
"find file_name.png"
I got IFF (little-endian) data, Web/P image
So to convert the webp files to png
we have to install webp
sudo apt install webp
Then execute the below command to convert the files to png with same naming
find . -name '*.png' -exec sh -c 'if file "$0" | grep -q "Web/P image"; then dwebp "$0" -o "${0%.png}.png" && mv "${0%.png}.png" "$0"; fi' {} \;
Now rerun the apktool build command and see if it works :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment