iBotPeaches / Apktool

A tool for reverse engineering Android apk files
https://apktool.org/
Apache License 2.0
19.79k stars 3.56k forks source link

[BUG] webp appears as png - this breaks building the apk #3649

Closed dzkh closed 1 month ago

dzkh commented 1 month ago

Information

  1. Apktool Version (apktool -version) - 2.9.3
  2. Operating System (Mac, Linux, Windows) - Windows
  3. APK From? (Playstore, ROM, Other) - Huawei App Store, Google Play Store BaiduNavigation app in chinese.
  4. Java Version (java --version) - Jetbrains OpenJDK 17, Oracle JDK 22

APK contains several webp files which being unpacked as PNG-files and thus breaks assembly of APK because of file signature/file extension mismatch during the "Building Resources" phase.

\res\drawable-hdpi\big_default_img.png: error: failed to read PNG signature: file does not start with PNG signature.

BaiduMap.apk 19.8.0 (1355) downloaded from the Huawei App Store or Google Play Store. Version is latest. Google Play: https://play.google.com/store/apps/details?id=com.baidu.BaiduMap&hl=en_US

Steps to Reproduce

  1. `apktool d com.baidu.BaiduMap.apk
  2. `apktool b com.baidu.BaiduMap.apk

Questions to ask before submission

  1. Have you tried apktool d, apktool b without changing anything? - YES
  2. If you are trying to install a modified apk, did you resign it? ---
  3. Are you using the latest apktool version? YES
iBotPeaches commented 1 month ago

I guess the question being - were they webm that apktool improperly treated as png? Or png that are improperly webm?

dzkh commented 1 month ago

I guess the question being - were they webm that apktool improperly treated as png? Or png that are improperly webm?

oh, sorry, am talking about webp. That webp files are webp (with RIFF signature) inside the apk and they appear as png after extraction but still with the RIFF sigrature. The signature loooks like this: RIFFR WEBPVP8 but this is a still static graphic file like PNG. So, yes webp improperly treated by apktool as png.

iBotPeaches commented 1 month ago

Okay, can you run unzip -l apk.apk | grep 'webp' over the apk?

dzkh commented 1 month ago

Okay, can you run unzip -l apk.apk | grep 'webp' over the apk?

list.txt

Screenshot 2024-07-22 at 22 14 18

1324 occurences.

By the way, no of errors like:

failed to read PNG signature: file does not start with PNG signature.

during assembly is about fifteen or even less for that particular APK

iBotPeaches commented 1 month ago

I don't think Apktool can do anything here. These are labeled as PNGs in the source application and Apktool is not reading magic or determining the real image format.

F: Decoding file res/drawable-hdpi-v4/big_default_img.png to res/drawable-hdpi/big_default_img.png