Apktool icon indicating copy to clipboard operation
Apktool copied to clipboard

[BUG] Recompilation error on "Hungry Shark Evolution" APK after decompiling with Apktool

Open solomode0001 opened this issue 8 months ago • 3 comments

Information

  1. Apktool Version (apktool -version) - v2.11.1-20-a08eabb5-SNAPSHOT
  2. Operating System (Windows)
  3. APK From? (Playstore)

Stacktrace/Logcat

C:\Users\pc\Downloads\MEmu Download\Games>java -jar apktool.jar d -m -f HungrySharkEvo.apk
I: Using Apktool v2.11.1-20-a08eabb5-SNAPSHOT on HungrySharkEvo.apk with 8 threads
I: Baksmaling classes.dex...
I: Baksmaling classes2.dex...
I: Baksmaling classes3.dex...
I: Loading resource table...
I: Baksmaling assets/audience_network.dex...
I: Decoding file-resources...
I: Loading resource table from file: C:\Users\pc\AppData\Local\apktool\framework\1.apk
I: Decoding values */* XMLs...
I: Decoding AndroidManifest.xml with resources...
I: Copying original files...
I: Copying assets...
I: Copying lib...
I: Copying unknown files...

C:\Users\pc\Downloads\MEmu Download\Games>java -jar apktool.jar b -o newApk.apk HungrySharkEvo
I: Using Apktool v2.11.1-20-a08eabb5-SNAPSHOT on HungrySharkEvo.apk with 8 threads
I: Checking whether sources have changed...
I: Smaling smali folder into classes.dex...
I: Checking whether sources have changed...
I: Checking whether sources have changed...
I: Checking whether sources have changed...
I: Smaling smali_classes2 folder into classes2.dex...
I: Smaling smali_assets folder into assets.dex...
I: Smaling smali_classes3 folder into classes3.dex...
I: Checking whether resources have changed...
I: Building resources with aapt2...
W: C:\Users\pc\Downloads\MEmu Download\Games\HungrySharkEvo\res\xml\appsflyer_backup_rules.xml.meta:1: error: syntax error.
W: C:\Users\pc\Downloads\MEmu Download\Games\HungrySharkEvo\res\xml\appsflyer_backup_rules.xml.meta: error: file failed to compile.
Exception in thread "main" brut.androlib.exceptions.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\pc\AppData\Local\Temp\brut_util_Jar_176107265156199050971313808596442632119.tmp, compile, --dir, C:\Users\pc\Downloads\MEmu Download\Games\HungrySharkEvo\res, --legacy, -o, C:\Users\pc\Downloads\MEmu Download\Games\HungrySharkEvo\build\resources.zip]
        at brut.androlib.AaptInvoker.invoke(SourceFile:105)
        at brut.androlib.ApkBuilder.buildResources(SourceFile:325)
        at brut.apktool.Main.main(SourceFile:96)
Caused by: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\pc\AppData\Local\Temp\brut_util_Jar_176107265156199050971313808596442632119.tmp, compile, --dir, C:\Users\pc\Downloads\MEmu Download\Games\HungrySharkEvo\res, --legacy, -o, C:\Users\pc\Downloads\MEmu Download\Games\HungrySharkEvo\build\resources.zip]
        at brut.util.OS.exec(SourceFile:148)
        at brut.androlib.AaptInvoker.invoke(SourceFile:101)
        ... 2 more

Steps to Reproduce

  1. apktool

APK

You can download it easily on apkpure (Hungry Shark Evolution)

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? - Yes
  3. Are you using the latest apktool version? - Yes

solomode0001 avatar May 19 '25 13:05 solomode0001

Can't imagine how they even built this app with a raw text file in res/xml. This shouldn't be even possible, that's why you're getting an error. aapt2 tries to parse it as an XML, but it's not an XML.

    [ResTable_type] chunkSize: 284 headerSize: 84 id: 0x15 name: xml flags: 0x00 (DENSE) entryCount: 10 entryStart: 124 config:
      [ResTable_entry] id: 0x0000 name: appsflyer_backup_rules keyIndex: 2979 size: 8 flags: 0x0000
        [Res_value] size: 8 dataType: 0x03 data: 0x00000143 ((file) res/xml/appsflyer_backup_rules.xml type=XML)
      [ResTable_entry] id: 0x0001 name: appsflyer_backup_rules.xml keyIndex: 2980 size: 8 flags: 0x0000
        [Res_value] size: 8 dataType: 0x03 data: 0x00000144 ((file) res/xml/appsflyer_backup_rules.xml.xml.meta)

IgorEisberg avatar May 21 '25 21:05 IgorEisberg

I'm not a Unity developer, but as far as I know, *.meta files are only used inside the Unity Editor and are not part of the final Android APK (please correct me if I'm wrong).

  • Removed \res\xml\appsflyer_backup_rules.xml.meta
  • Removed line <public type="xml" name="appsflyer_backup_rules.xml" id="0x7f150001" /> from \res\values\public.xml

[!TIP] public.xml has files without extensions, so appsflyer_backup_rules.xml.meta without extension isappsflyer_backup_rules.xml

Then at least I could build the app successfully.

[!NOTE] I didn't test the app after rebuilding.

@IgorEisberg — unlike Apktool, perhaps there could be a way to automatically exclude non-XML files from being compiled under res/xml ?

sipsuru avatar Jun 04 '25 03:06 sipsuru

I'm not a Unity developer, but as far as I know, *.meta files are only used inside the Unity Editor and are not part of the final Android APK (please correct me if I'm wrong).

  • Removed \res\xml\appsflyer_backup_rules.xml.meta
  • Removed line <public type="xml" name="appsflyer_backup_rules.xml" id="0x7f150001" /> from \res\values\public.xml

Tip

public.xml has files without extensions, so appsflyer_backup_rules.xml.meta without extension isappsflyer_backup_rules.xml

Then at least I could build the app successfully.

Note

I didn't test the app after rebuilding.

@IgorEisberg — unlike Apktool, perhaps there could be a way to automatically exclude non-XML files from being compiled under res/xml ?

Such a tiny edge case isn't really worth making decisions for what to automatically do for arbitrary resource types (XML files are expected not only in res/xml), and more types are accepted than xml (xsl for example). What is and what isn't an XML is also arbitrary. Also, aapt2 allows to recompile arbitrary unsuffixed files in res dirs without errors. So, a very tiny edge case that's not worth automating and adding bugs in the process.

IgorEisberg avatar Jun 04 '25 04:06 IgorEisberg