iBotPeaches/Apktool

[BUG] brut.common.BrutException when building Android 12 app with Material3 color scheme

liorstov opened this issue · 4 comments

Information

  1. Apktool Version (apktool -version) - 2.6.0
  2. Operating System (Mac, Linux, Windows) - mac
  3. APK From? (Playstore, ROM, Other) - PLaystore

Stacktrace/Logcat

apktool b  /Users/***/work/appsApk/testApp --use-aapt2
I: Using Apktool 2.6.0
I: Checking whether sources has changed...
I: Checking whether sources has changed...
I: Checking whether sources has changed...
I: Checking whether sources has changed...
I: Checking whether sources has changed...
I: Checking whether sources has changed...
I: Checking whether resources has changed...
I: Building resources...
W: /Users/stlior/work/appsApk/testApp/res/values/colors.xml:74: error: resource android:color/Teal_800 is private.
W: /Users/stlior/work/appsApk/testApp/res/values/colors.xml:75: error: resource android:color/Teal_700 is private.
W: /Users/stlior/work/appsApk/testApp/res/values/colors.xml:76: error: resource android:color/Blue_700 is private.
W: /Users/stlior/work/appsApk/testApp/res/values/colors.xml:77: error: resource android:color/Red_800 is private.
W: /Users/stlior/work/appsApk/testApp/res/values/colors.xml:78: error: resource android:color/Red_700 is private.
W: /Users/stlior/work/appsApk/testApp/res/values/colors.xml:79: error: resource android:color/Purple_800 is private.
W: /Users/stlior/work/appsApk/testApp/res/values/colors.xml:80: error: resource android:color/Purple_700 is private.
W: /Users/stlior/work/appsApk/testApp/res/values/colors.xml:81: error: resource android:color/Pink_800 is private.
W: /Users/stlior/work/appsApk/testApp/res/values/colors.xml:82: error: resource android:color/Pink_700 is private.
W: /Users/stlior/work/appsApk/testApp/res/values/colors.xml:83: error: resource android:color/Indigo_800 is private.
W: /Users/stlior/work/appsApk/testApp/res/values/colors.xml:84: error: resource android:color/Indigo_700 is private.
W: /Users/stlior/work/appsApk/testApp/res/values/colors.xml:85: error: resource android:color/GM2_grey_800 is private.
W: /Users/stlior/work/appsApk/testApp/res/values/colors.xml:86: error: resource android:color/Blue_800 is private.
W: /Users/stlior/work/appsApk/testApp/res/values/colors.xml:87: error: resource android:color/background_cache_hint_selector_device_default is private.
W: /Users/stlior/work/appsApk/testApp/res/values/colors.xml:88: error: resource android:color/autofilled_highlight is private.
W: /Users/stlior/work/appsApk/testApp/res/values/colors.xml:89: error: resource android:color/accent_device_default is private.
W: /Users/stlior/work/appsApk/testApp/res/values/colors.xml:90: error: resource android:color/autofill_background_material_light is private.
W: /Users/stlior/work/appsApk/testApp/res/values/colors.xml:91: error: resource android:color/autofill_background_material_dark is private.
W: /Users/stlior/work/appsApk/testApp/res/values/colors.xml:92: error: resource android:color/accessibility_focus_highlight is private.
W: /Users/stlior/work/appsApk/testApp/res/values/colors.xml:93: error: resource android:color/accent_material_light is private.
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/var/folders/8_/tjjzqkrx15l6l0rgw6jqgcdm0000gn/T/brut_util_Jar_85297205925616822706789494002393446046.tmp, link, -o, /var/folders/8_/tjjzqkrx15l6l0rgw6jqgcdm0000gn/T/APKTOOL1054337590762445014.tmp, --package-id, 127, --min-sdk-version, 31, --target-sdk-version, 32, --version-code, 1, --version-name, 1.0, --no-auto-version, --no-version-vectors, --no-version-transitions, --no-resource-deduping, -e, /var/folders/8_/tjjzqkrx15l6l0rgw6jqgcdm0000gn/T/APKTOOL1158101774587448793.tmp, -0, arsc, -I, /Users/stlior/Library/apktool/framework/1.apk, --manifest, /Users/stlior/work/appsApk/testApp/AndroidManifest.xml, /Users/stlior/work/appsApk/testApp/build/resources.zip]


Happens on an empty app which uses Material3 like so:

</style>
    <style name="Theme.MyApp" parent="Theme.Material3.Light.NoActionBar">
        ...
        <item name="materialButtonStyle">@style/Widget.AppCompat.ActionBar</item>
        ...
    </style>

Never happened in previous android releases. The generated colors.xml file contain private resources like so :

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="m3_ref_palette_dynamic_neutral0">@android:color/Teal_800</color>
    <color name="m3_ref_palette_dynamic_neutral10">@android:color/Teal_700</color>
    <color name="m3_ref_palette_dynamic_neutral100">@android:color/Blue_700</color>
    <color name="m3_ref_palette_dynamic_neutral20">@android:color/Red_800</color>
    <color name="m3_ref_palette_dynamic_neutral30">@android:color/Red_700</color>
    ....
....

Steps to Reproduce

  1. apktool d
  2. apktool b --use-aapt2

Frameworks

If this APK is from an OEM ROM (Samsung, HTC, LG). Please attach framework files
(.apks that live in /system/framework or /system/priv-app)

APK

If this APK can be freely shared, please upload/attach a link to it.

Questions to ask before submission

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

Same issue, apk in question is Tachiyomi, https://github.com/tachiyomiorg/tachiyomi/releases/tag/v0.13.1

I don't think I see an issue here. Yes build tools (especially aapt2 are getting strict-er at compile time). Not sure what you expect Apktool to do in this circumstance - so closing as intended.

in your colors.xml, replace all @android with @*android

iKlsR commented

@rathaROG Many thanks, that did the trick.