iBotPeaches / Apktool

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

[BUG] Error building resources extracted from split Chrome APK #3352

Open weary-adventurer opened 1 year ago

weary-adventurer commented 1 year ago

Information

  1. Apktool Version (apktool -version) - 2.8.1
  2. Operating System (Mac, Linux, Windows) - Windows 10
  3. APK From? (Playstore, ROM, Other) - Playstore (Apkmirror)
  4. Java Version (java --version) - openjdk 17.0.7 2023-04-18

Stacktrace/Logcat

With --use-aapt2:

λ java -jar apktool_2.8.1.jar b --use-aapt2 base -o base_output.apk
I: Using Apktool 2.8.1
I: Checking whether sources has changed...
I: Checking whether resources has changed...
I: Building resources...
W: X:\Test\base\res\values\attrs.xml:53: error: duplicate symbol '@null'.
W: X:\Test\base\res\values\attrs.xml:52: note: first defined here.
...
W: X:\Test\base\res\values\attrs.xml:2569: note: first defined here.
W: X:\Test\base\res\values\attrs.xml:2578: note: first defined here.
brut.androlib.exceptions.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\User\AppData\Local\Temp\brut_util_Jar_62537967109653429448808130018634846395.tmp, compile, --dir, X:\Test\base\res, --legacy, -o, X:\Test\base\build\resources.zip]

Without --use-aapt2:

λ java -jar apktool_2.8.1.jar b base -o base_output.apk
I: Using Apktool 2.8.1
I: Checking whether sources has changed...
I: Checking whether resources has changed...
I: Building resources...
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
...
W: X:\Test\base\res\values\public.xml:153: error: Public symbol id/automatic declared here is not defined.
W: X:\Test\base\res\values\public.xml:420: error: Public symbol id/custom declared here is not defined.
...
W: X:\Test\base\res\values\attrs.xml:53: error: Error: No resource found that matches the given name: id '@null'.
W: X:\Test\base\res\values\attrs.xml:113: error: Error: No resource found that matches the given name: id 'none'.
...
W: 
brut.androlib.exceptions.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\User\AppData\Local\Temp\brut_util_Jar_17585145126878365954695040809091876981.tmp, p, --forced-package-id, 127, --min-sdk-version, 29, --target-sdk-version, 34, --version-code, 593814038, --version-name, 117.0.5938.140, --no-version-vectors, -F, C:\Users\User\AppData\Local\Temp\APKTOOL14066161238022795413.tmp, -e, C:\Users\User\AppData\Local\Temp\APKTOOL17740274838755450449.tmp, -0, arsc, -I, C:\Users\User\AppData\Local\apktool\framework\1.apk, -S, X:\Test\base\res, -M, X:\Test\base\AndroidManifest.xml]

Steps to Reproduce

  1. apktool d base.apk
  2. apktool b base -o base_rebuilt.apk OR apktool b base --use-aapt2 -o base_rebuilt.apk

APK

Just the APK: base.apk.zip

Note: This is a split Chrome 117 APK, can be extracted from original .apkm here: https://www.apkmirror.com/apk/google-inc/chrome/chrome-117-0-5938-140-release/google-chrome-fast-secure-117-0-5938-140-9-android-apk-download/

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
weary-adventurer commented 1 year ago

I've also tried a different aapt2 version from latest build tools.

Same error with:

iBotPeaches commented 1 year ago

May you try the upcoming build here? https://github.com/iBotPeaches/Apktool/suites/16733967486/artifacts/956092470

I recognize that error as something already resolved.

weary-adventurer commented 1 year ago

I've tried this version and it seems the errors are different now.

Without arguments:

I: Using Apktool v2.8.1-68-77b4229d-SNAPSHOT
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether resources has changed...
I: Building resources...
W: Failed to generate resource table for split ''
W: X:\test\_unpacked\res\values-v34\colors.xml:5: error: Error: Resource is not public. (at 'APKTOOL_DUMMYVAL_0x7f0709b2' with value '@android:color/accent_material_light').
W:
brut.androlib.exceptions.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\User\AppData\Local\Temp\brut_util_Jar_1573041273733491312796520576701119900.tmp, p, --forced-package-id, 127, --min-sdk-version, 29, --target-sdk-version, 34, --version-code, 593814038, --version-name, 117.0.5938.140, --no-version-vectors, -F, C:\Users\User\AppData\Local\Temp\APKTOOL1100759794303156844.tmp, -e, C:\Users\User\AppData\Local\Temp\APKTOOL15263151198938633053.tmp, -0, arsc, -I, C:\Users\User\AppData\Local\apktool\framework\1.apk, -S, X:\test\_unpacked\res, -M, X:\test\_unpacked\AndroidManifest.xml]

With --use-aapt2:

I: Using Apktool v2.8.1-68-77b4229d-SNAPSHOT
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether resources has changed...
I: Building resources...
W: X:\test\_unpacked\res\values-v34\colors.xml:5: error: resource android:color/accent_material_light is private.
W: X:\test\_unpacked\res\values-night-v34\colors.xml:6: error: resource android:color/bright_foreground_light is private.
W: X:\test\_unpacked\res\values\styles.xml:4: error: expected flags but got (raw string) APKTOOL_MISSING_0x7f0103fc.
W: X:\test\_unpacked\res\values\styles.xml:4817: error: expected flags but got (raw string) APKTOOL_MISSING_0x7f0107f5.
W: X:\test\_unpacked\res\values\styles.xml:4833: error: expected flags but got (raw string) APKTOOL_MISSING_0x7f010504.
W: X:\test\_unpacked\res\values\styles.xml:4865: error: expected flags but got (raw string) APKTOOL_MISSING_0x7f010504.
W: X:\test\_unpacked\res\values\styles.xml:5384: error: expected enum but got (raw string) 2.
W: X:\test\_unpacked\res\values\styles.xml:10189: error: resource android:color/bright_foreground_dark_disabled is private. W: X:\test\_unpacked\res\values\styles.xml:10203: error: resource android:color/btn_default_material_dark is private.
W: X:\test\_unpacked\res\values\styles.xml:10204: error: resource android:color/btn_leanback_color is private.
W: X:\test\_unpacked\res\values\styles.xml:10205: error: resource android:color/bright_foreground_dark_inverse is private.
W: X:\test\_unpacked\res\values\styles.xml:10206: error: resource android:color/btn_default_material_light is private.
W: X:\test\_unpacked\res\values\styles.xml:10207: error: resource android:color/btn_leanback_focused is private.
W: X:\test\_unpacked\res\values\styles.xml:10208: error: resource android:color/background_floating_device_default_light is private.
W: X:\test\_unpacked\res\values\styles.xml:10209: error: resource android:color/background_device_default_light is private. W: X:\test\_unpacked\res\values\styles.xml:10210: error: resource android:color/car_action1 is private.
W: X:\test\_unpacked\res\values\styles.xml:10211: error: resource android:color/car_action1_dark is private.
W: X:\test\_unpacked\res\values\styles.xml:10212: error: resource android:color/background_holo_light is private.
W: X:\test\_unpacked\res\values\styles.xml:10213: error: resource android:color/background_floating_material_light is private.
W: X:\test\_unpacked\res\values\styles.xml:10214: error: resource android:color/car_blue_100 is private.
brut.androlib.exceptions.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\User\AppData\Local\Temp\brut_util_Jar_6336769292040621121824582984158182377.tmp, link, -o, C:\Users\User\AppData\Local\Temp\APKTOOL3244941944423443864.tmp, --package-id, 127, --min-sdk-version, 29, --target-sdk-version, 34, --version-code, 593814038, --version-name, 117.0.5938.140, --no-auto-version, --no-version-vectors, --no-version-transitions, --no-resource-deduping, --allow-reserved-package-id, --no-compile-sdk-metadata, -e, C:\Users\User\AppData\Local\Temp\APKTOOL16665445829855389215.tmp, -0, arsc, -I, C:\Users\User\AppData\Local\apktool\framework\1.apk, --manifest, X:\test\_unpacked\AndroidManifest.xml, X:\test\_unpacked\build\resources.zip]
iBotPeaches commented 1 year ago

I got a slightly different error.

W: /media/ibotpeaches/AOSP/Apktool/3352/base/res/values/styles.xml:4: error: Error: String types not allowed (at 'APKTOOL_DUMMYVAL_0x7f050216' with value 'APKTOOL_MISSING_0x7f0103fc').

Which does look odd.

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="APKTOOL_DUMMYVAL_0x7f150000">
        <item name="APKTOOL_DUMMYVAL_0x7f050216">APKTOOL_MISSING_0x7f0103fc</item>
        <item name="APKTOOL_DUMMYVAL_0x7f0502fe">@drawable/APKTOOL_DUMMYVAL_0x7f0901e8</item>
    </style>

In this default configuration of res mode in removal, we should have killed that resource. I'll investigate that aspect.