Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Cannot recompile Pixel SystemUI #3392

Closed
thecrybaby opened this issue Oct 10, 2023 · 9 comments · Fixed by #3396
Closed

[BUG] Cannot recompile Pixel SystemUI #3392

thecrybaby opened this issue Oct 10, 2023 · 9 comments · Fixed by #3396

Comments

@thecrybaby
Copy link

Information

  1. Apktool Version (apktool -version) - 2.9.0
  2. Operating System (Mac, Linux, Windows) - Linux
  3. APK From? (Playstore, ROM, Other) - Stock Pixel barbet
  4. Java Version (java --version) - 11.0.20.1

Stacktrace/Logcat

admin@admin:~/apps$ apktool d SystemUIGoogle.apk
I: Using Apktool 2.9.0 on SystemUIGoogle.apk
I: Loading resource table...
I: Decoding file-resources...
I: Loading resource table from file: /home/admin/.local/share/apktool/framework/1.apk
I: Decoding values */* XMLs...
I: Decoding AndroidManifest.xml with resources...
I: Regular manifest package...
I: Baksmaling classes.dex...
I: Baksmaling classes2.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
I: Copying META-INF/services directory



admin@admin:~/apps$ apktool b SystemUIGoogle
I: Using Apktool 2.9.0
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes2 folder into classes2.dex...
I: Checking whether resources has changed...
I: Building resources...
W: /home/admin/apps/SystemUIGoogle/res/values/arrays.xml:84: error: resource android:string/status_bar_vpn is private.
W: /home/admin/apps/SystemUIGoogle/res/values/arrays.xml:85: error: resource android:string/status_bar_battery is private.
W: /home/admin/apps/SystemUIGoogle/res/values/arrays.xml:86: error: resource android:string/status_bar_camera is private.
W: /home/admin/apps/SystemUIGoogle/res/values/arrays.xml:171: error: resource android:string/status_bar_screen_record is private.
W: /home/admin/apps/SystemUIGoogle/res/values/arrays.xml:172: error: resource android:string/status_bar_hotspot is private.
W: /home/admin/apps/SystemUIGoogle/res/values/bools.xml:21: error: resource android:bool/config_enableLockScreenRotation is private.
W: /home/admin/apps/SystemUIGoogle/res/values/colors.xml:23: error: resource android:color/background_material_light is private.
W: /home/admin/apps/SystemUIGoogle/res/values-night/colors.xml:4: error: resource android:color/background_material_dark is private.
W: /home/admin/apps/SystemUIGoogle/res/values/colors.xml:24: error: resource android:color/primary_text_default_material_light is private.
W: /home/admin/apps/SystemUIGoogle/res/values-night/colors.xml:5: error: resource android:color/primary_text_default_material_dark is private.
W: /home/admin/apps/SystemUIGoogle/res/values/colors.xml:75: error: resource android:color/foreground_material_dark is private.
W: /home/admin/apps/SystemUIGoogle/res/values/colors.xml:79: error: resource android:color/foreground_material_dark is private.
W: /home/admin/apps/SystemUIGoogle/res/values/colors.xml:298: error: resource android:color/background_device_default_light is private.
W: /home/admin/apps/SystemUIGoogle/res/values-night/colors.xml:29: error: resource android:color/background_device_default_dark is private.
W: /home/admin/apps/SystemUIGoogle/res/values/colors.xml:301: error: resource android:color/accent_device_default is private.
W: /home/admin/apps/SystemUIGoogle/res/values-night/colors.xml:65: error: resource android:color/notification_primary_text_color_dark is private.
W: /home/admin/apps/SystemUIGoogle/res/values/colors.xml:368: error: resource android:color/accent_device_default is private.
W: /home/admin/apps/SystemUIGoogle/res/values/colors.xml:369: error: resource android:color/notification_primary_text_color_light is private.
W: /home/admin/apps/SystemUIGoogle/res/values/colors.xml:370: error: resource android:color/notification_primary_text_color_dark is private.
W: /home/admin/apps/SystemUIGoogle/res/values/colors.xml:475: error: resource android:color/text_color_primary_device_default_dark is private.
brut.androlib.exceptions.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/tmp/brut_util_Jar_20178106122052190306248657875793045585.tmp, link, -o, /tmp/APKTOOL1613291305428299689.tmp, --package-id, 127, --min-sdk-version, 34, --target-sdk-version, 34, --version-code, 34, --version-name, 14, --no-auto-version, --no-version-vectors, --no-version-transitions, --no-resource-deduping, --allow-reserved-package-id, --no-compile-sdk-metadata, -e, /tmp/APKTOOL12871415362735941631.tmp, -0, arsc, -I, /home/admin/.local/share/apktool/framework/1.apk, --manifest, /home/admin/apps/SystemUIGoogle/AndroidManifest.xml, /home/admin/apps/SystemUIGoogle/build/resources.zip]


Steps to Reproduce

  1. apktool d SystemUIGoogle.apk
  2. apktool b SystemUIGoogle
    Also tried importing frameworks-res.apk from same build but same error

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.

APK Link

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? N/A
  3. Are you using the latest apktool version? yes
@iBotPeaches
Copy link
Owner

This is common when the upgraded build tools (aapt2) are more strict than the original tools used to build application. As those errors suggest - this application is using private resources, which should be avoided and rather copied into project.

However, as you might imagine - changing every application you choose to decode to build up to the modern build tool standards may be insane.

So I prepped a workaround to aapt2 to remove this restriction - iBotPeaches/platform_frameworks_base#14

Also saying that though - who knows if this will work or just move the problem downstream.

So tldr - holding for a bit.

@iBotPeaches
Copy link
Owner

That test semi-worked. You just moved to a new issue, which is a known one in the backlog affecting more and more applications.

➜  3392 apktool b SystemUIGoogle            
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
I: Using Apktool v2.9.0-1-d2599874-SNAPSHOT
I: Checking whether resources has changed...
I: Building resources...
W: /media/ibotpeaches/AOSP/Apktool/3392/SystemUIGoogle/res/animator/mtrl_card_state_list_anim.xml:4: error: attribute state_dragged (aka com.android.systemui:state_dragged) not found.
W: /media/ibotpeaches/AOSP/Apktool/3392/SystemUIGoogle/res/color/mtrl_card_view_foreground.xml:5: error: attribute state_dragged (aka com.android.systemui:state_dragged) not found.
W: /media/ibotpeaches/AOSP/Apktool/3392/SystemUIGoogle/res/color/mtrl_card_view_foreground.xml:6: error: attribute state_dragged (aka com.android.systemui:state_dragged) not found.
W: /media/ibotpeaches/AOSP/Apktool/3392/SystemUIGoogle/res/color/mtrl_card_view_ripple.xml:5: error: attribute state_dragged (aka com.android.systemui:state_dragged) not found.
W: /media/ibotpeaches/AOSP/Apktool/3392/SystemUIGoogle/res/drawable/qs_media_background.xml:2: error: attribute highlight (aka com.android.systemui:highlight) not found.

#3129 (comment)

@thecrybaby
Copy link
Author

That test semi-worked. You just moved to a new issue, which is a known one in the backlog affecting more and more applications.

➜  3392 apktool b SystemUIGoogle            
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
I: Using Apktool v2.9.0-1-d2599874-SNAPSHOT
I: Checking whether resources has changed...
I: Building resources...
W: /media/ibotpeaches/AOSP/Apktool/3392/SystemUIGoogle/res/animator/mtrl_card_state_list_anim.xml:4: error: attribute state_dragged (aka com.android.systemui:state_dragged) not found.
W: /media/ibotpeaches/AOSP/Apktool/3392/SystemUIGoogle/res/color/mtrl_card_view_foreground.xml:5: error: attribute state_dragged (aka com.android.systemui:state_dragged) not found.
W: /media/ibotpeaches/AOSP/Apktool/3392/SystemUIGoogle/res/color/mtrl_card_view_foreground.xml:6: error: attribute state_dragged (aka com.android.systemui:state_dragged) not found.
W: /media/ibotpeaches/AOSP/Apktool/3392/SystemUIGoogle/res/color/mtrl_card_view_ripple.xml:5: error: attribute state_dragged (aka com.android.systemui:state_dragged) not found.
W: /media/ibotpeaches/AOSP/Apktool/3392/SystemUIGoogle/res/drawable/qs_media_background.xml:2: error: attribute highlight (aka com.android.systemui:highlight) not found.

#3129 (comment)

Can you share the updated apktool with resolved resource referencing error? Thanks

@iBotPeaches
Copy link
Owner

Can you share the updated apktool with resolved resource referencing error? Thanks

Sorry I cannot. That build was only with Linux binaries and posting dirty test builds I tend to avoid.

@IgorEisberg
Copy link
Contributor

That test semi-worked. You just moved to a new issue, which is a known one in the backlog affecting more and more applications.

➜  3392 apktool b SystemUIGoogle            
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
I: Using Apktool v2.9.0-1-d2599874-SNAPSHOT
I: Checking whether resources has changed...
I: Building resources...
W: /media/ibotpeaches/AOSP/Apktool/3392/SystemUIGoogle/res/animator/mtrl_card_state_list_anim.xml:4: error: attribute state_dragged (aka com.android.systemui:state_dragged) not found.
W: /media/ibotpeaches/AOSP/Apktool/3392/SystemUIGoogle/res/color/mtrl_card_view_foreground.xml:5: error: attribute state_dragged (aka com.android.systemui:state_dragged) not found.
W: /media/ibotpeaches/AOSP/Apktool/3392/SystemUIGoogle/res/color/mtrl_card_view_foreground.xml:6: error: attribute state_dragged (aka com.android.systemui:state_dragged) not found.
W: /media/ibotpeaches/AOSP/Apktool/3392/SystemUIGoogle/res/color/mtrl_card_view_ripple.xml:5: error: attribute state_dragged (aka com.android.systemui:state_dragged) not found.
W: /media/ibotpeaches/AOSP/Apktool/3392/SystemUIGoogle/res/drawable/qs_media_background.xml:2: error: attribute highlight (aka com.android.systemui:highlight) not found.

#3129 (comment)

I concur. Doesn't look like anything to do with Apktool, and I don't actually understand how such APKs are even valid when they clearly have missing attribute resources... and I have no logical solutions for that.
Android 13: https://dpaste.com/94TZBP8CR
Android 14: https://dpaste.com/5NG82KFD5

@iBotPeaches
Copy link
Owner

@IgorEisberg - I'm investigating those odd issues in #3129 (comment). I'm just going to retrace some steps and dig into alias attributes, splits, etc and see if I'm missing something.

@IgorEisberg
Copy link
Contributor

IgorEisberg commented Oct 11, 2023

@IgorEisberg - I'm investigating those odd issues in #3129 (comment). I'm just going to retrace some steps and dig into alias attributes, splits, etc and see if I'm missing something.

Strangely, when I search the missing attributes in resources.arsc using a hex editor, I can find them.
However, can't find them using aapt2 no matter what I try to dump, not even using "aapt2 dump strings".
Some of these attributes have enum/flag values, so when decompiled, the resulting value is a raw value rather than its name, so even if I insert the missing attribute definitions, the APK cannot be recompiled.

Example:
The missing definition inserted to attrs.xml:

    <attr name="layout_constraintLeft_toLeftOf" format="reference">
        <enum name="parent" value="0" />
    </attr>

But the decompiled attribute in XML is:

app:layout_constraintLeft_toLeftOf="0"

So when trying to recompile the APK:

error: '0' is incompatible with attribute layout_constraintLeft_toLeftOf (attr) reference|enum [parent=0].

@iBotPeaches
Copy link
Owner

I'm just happy to know I wasn't going crazy and couldn't make sense of those attributes.

@IgorEisberg
Copy link
Contributor

I'm just happy to know I wasn't going crazy and couldn't make sense of those attributes.

Nah, I'm going crazy for a while now trying to make sense of this.
Edited my comment multiple times cause my brain is already fried.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants