Apktool: attributes in ^attr-privates.xml not found

Information

  1. Apktool Version (apktool -version) - 2.3.0
  2. Operating System (Mac, Linux, Windows) - Win10
  3. APK From? (Playstore, ROM, Other) - HTC Oreo SystemUI

Stacktrace/Logcat

W: C:\Android\reverse_engineering\SystemUI\res\values\public.xml:1193: error: Public symbol ^attr-private/viewType declared here is not defined.
W: C:\Android\reverse_engineering\SystemUI\res\values\public.xml:1194: error: Public symbol ^attr-private/voiceIcon declared here is not defined.
W: C:\Android\reverse_engineering\SystemUI\res\values\public.xml:1195: error: Public symbol ^attr-private/widgetLayout declared here is not defined.
Exception in thread "main" W: C:\Android\reverse_engineering\SystemUI\res\values\public.xml:1196: error: Public symbol ^attr-private/wifi_friction declared here is not defined.
W: C:\Android\reverse_engineering\SystemUI\res\values\public.xml:1197: error: Public symbol ^attr-private/wifi_signal declared here is not defined.
brut.androlib.AndrolibException: brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\J3F4F~1.DUO\AppData\Local\Temp\brut_util_Jar_1618230815674308433.tmp, p, --forced-package-id, 127, --min-sdk-version, 23, --target-sdk-version, 26, --version-code, 26, --version-name, 8.0.0, --no-version-vectors, -F, C:\Users\J3F4F~1.DUO\AppData\Local\Temp\APKTOOL224544575642684951.tmp, -0, arsc, -0, webp, -0, arsc, -I, C:\Users\J.Duong\AppData\Local\apktool\framework\1.apk, -S, C:\Android\reverse_engineering\SystemUI\res, -M, C:\Android\reverse_engineering\SystemUI\AndroidManifest.xml]
        at brut.androlib.Androlib.buildResourcesFull(Androlib.java:485)
        at brut.androlib.Androlib.buildResources(Androlib.java:419)
        at brut.androlib.Androlib.build(Androlib.java:318)
        at brut.androlib.Androlib.build(Androlib.java:270)
        at brut.apktool.Main.cmdBuild(Main.java:224)
        at brut.apktool.Main.main(Main.java:75)
Caused by: brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\J3F4F~1.DUO\AppData\Local\Temp\brut_util_Jar_1618230815674308433.tmp, p, --forced-package-id, 127, --min-sdk-version, 23, --target-sdk-version, 26, --version-code, 26, --version-name, 8.0.0, --no-version-vectors, -F, C:\Users\J3F4F~1.DUO\AppData\Local\Temp\APKTOOL224544575642684951.tmp, -0, arsc, -0, webp, -0, arsc, -I, C:\Users\J.Duong\AppData\Local\apktool\framework\1.apk, -S, C:\Android\reverse_engineering\SystemUI\res, -M, C:\Android\reverse_engineering\SystemUI\AndroidManifest.xml]
        at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:454)
        at brut.androlib.Androlib.buildResourcesFull(Androlib.java:471)
        ... 5 more
Caused by: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\J3F4F~1.DUO\AppData\Local\Temp\brut_util_Jar_1618230815674308433.tmp, p, --forced-package-id, 127, --min-sdk-version, 23, --target-sdk-version, 26, --version-code, 26, --version-name, 8.0.0, --no-version-vectors, -F, C:\Users\J3F4F~1.DUO\AppData\Local\Temp\APKTOOL224544575642684951.tmp, -0, arsc, -0, webp, -0, arsc, -I, C:\Users\J.Duong\AppData\Local\apktool\framework\1.apk, -S, C:\Android\reverse_engineering\SystemUI\res, -M, C:\Android\reverse_engineering\SystemUI\AndroidManifest.xml]
        at brut.util.OS.exec(OS.java:95)
        at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:448)
        ... 6 more

Steps to Reproduce

  1. apktool d SystemUI.apk

Failes loading resources?

I: Using Apktool 2.3.0 on SystemUI.apk I: Loading resource table… W: null W: null W: null W: null I: Decoding AndroidManifest.xml with resources… I: Loading resource table from file: C:\Users\J.Duong\AppData\Local\apktool\framework\1.apk I: Regular manifest package… I: Decoding file-resources… I: Decoding values / XMLs… I: Baksmaling classes.dex… I: Copying assets and libs… I: Copying unknown files… I: Copying original files…

Had first to delete the .9 suffix to from all pip_dismiss_scrim.9.png because of:

W: ERROR: 9-patch image C:\Android\reverse_engineering\SystemUI\res\drawable-xhdpi\pip_dismiss_scrim.9.png malformed. W: No marked region found along edge. W: Found along left edge.

then apktool b SystemUI brings the not found attributes warnings/errors

files.zip

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 44 (14 by maintainers)

Most upvoted comments

I did some investigating on this. In my understanding ^attr-private was introduced for the system level attributes. It allows a system application to say “this attribute is private” and not exposed.

We encountered a few bugs with this format because non standard OEMs like MIUI and Huawei used non-standard system packageIds which then weren’t allowed for that type.

@peter23 helped patched that here: https://github.com/iBotPeaches/platform_frameworks_base/commit/33c2310767810990c2e7af4b5645aa6848f168b8

Which introduced the --forced-package-id parameter, so we could force those non-standard OEMs who used values like (7) for a pkgId. However, this is a local application specific resource as denoted by the 0x7f type for 127.

So if we take a look at our logic in aapt1. That is the APP_PACKAGE_ID value referenced in the aapt1 sourcecode. The hacky patch above by @jtothe4n seems to rewrite the resourceIds from “^attr-private” to “attr” type which then is no longer bound by the constraints surronding the “^attr-private” type. Perhaps @peter23 has a bit more research here while I continue to investigate.

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: /home/t/Downloads/NfcNci/res/color/nfc_icon.xml:5: error: Error: Attribute is not public. (at 'color' with value '?android:^attr-private/closeItemLayout').
W: 
W: /home/t/Downloads/NfcNci/res/color-night/nfc_icon.xml:5: error: Error: Attribute is not public. (at 'color' with value '?android:^attr-private/clickColor').
W: 
brut.androlib.exceptions.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/tmp/brut_util_Jar_99407728250395273501252018577728462556.tmp, p, --forced-package-id, 127, --min-sdk-version, 33, --target-sdk-version, 33, --version-code, 33, --version-name, 13, --no-version-vectors, -F, /tmp/APKTOOL4632439189647828713.tmp, -e, /tmp/APKTOOL5399276601489171376.tmp, -0, arsc, -I, /home/t/.local/share/apktool/framework/1.apk, -S, /home/t/Downloads/NfcNci/res, -M, /home/t/Downloads/NfcNci/AndroidManifest.xml]

Running into the same error, any chance there’s been a solution?

Apktool v2.8.1 Linux Apk pulled from pixel 7 running Lineageos 20

Apologies if this isn’t the right place for this, I don’t use github very frequently. Thanks for any help

@iBotPeaches this esay fixed in aapt2 frameworks/base/tools/aapt2/ResourceUtils.cpp //add support private attributes //ignore /* if (!type.empty() && type != "attr") { return false; } */ https://github.com/MrIkso/sdk-tools/blob/6e2008c296093cb1585d91b89fbf9faf296c70cf/android-11/frameworks/base/tools/aapt2/ResourceUtils.cpp#L224

Can you put up a pull request to https://github.com/iBotPeaches/platform_frameworks_base on master? I’m confused a bit on the diff, are private attributes not attributes? I can’t follow the if statement.

@iBotPeaches Excuse me. How to make the aapt binary in the repo: https://github.com/iBotPeaches/platform_frameworks_base ?

https://github.com/iBotPeaches/Apktool/blob/master/INTERNAL.md#building-aapt-binaries

@iBotPeaches just tried version version 2.4.1 and this problem still exist. It has been around for 2 years now. Any chance of getting it fixed soon? How much money can I throw at you for it to be fixed 😃 I have tried clearing frameworks, using aapt2 and still same thing 😦 I don’t know how to package up the aapt2 so I can change

if (mPackageType == System) { p->movePrivateAttrs(); }

to

p->movePrivateAttrs();

And it seems like more and more apps are using ^attr-private now.

…I wrote that above. How else shall the app be working, if you just change the ressouce ids, but not he ones referenced in the code. decompile systemui, then run the .exe with the decompiled systemui dir as parameter. If its not clear now, I can’t help you, lol.