Closed jtothe4n closed 3 years ago
@iBotPeaches No ideas? :(
Android 5 added private attr
support, which we patched. I'm not sure whats going on in here yet.
The ^ in front has to be there? Looks weird to me.
Yep, that is valid. See AAPT2
TEST(JavaClassGeneratorTest, AttrPrivateIsWrittenAsAttr) {
std::unique_ptr<ResourceTable> table = test::ResourceTableBuilder()
.setPackageId(u"android", 0x01)
.addSimple(u"@android:attr/two", ResourceId(0x01010001))
.addSimple(u"@android:^attr-private/one", ResourceId(0x01010000))
.build();
JavaClassGenerator generator(table.get(), {});
std::stringstream out;
ASSERT_TRUE(generator.generate(u"android", &out));
std::string output = out.str();
EXPECT_NE(std::string::npos, output.find("public static final class attr"));
EXPECT_EQ(std::string::npos, output.find("public static final class ^attr-private"));
}
Ah, thx.
Never came across priv attributes since I mod the HTC framework. Seems SystemUI is the only one now. I tried to replace all ^attr-private with attr, threw me an error later, that attr ids expect to be 0x7f010000 instead of 0x7f050000. I could write me a tool doing that: continue the attr ids and replace the old id in all smalis with the new one. Would that work, or waste of time? :D
Waste of time. Private attributes are just that, private.
A resource ID is a 32 bit number of the form: PPTTNNNN. PP is the package the resource is for; TT is the type of the resource; NNNN is the name of the resource in that type. For applications resources, PP is always 0x7f. credit: https://stackoverflow.com/a/6646113/455008
0x7f050000
7f = PP
05 = TT
0000 = NNNN
Can't go changing types without breaking the resource-id.
I would change the type and the resource id to match the attr type id format.
priv attr: 0x7f050000 > attr: 0x7f01NNNN
Got it to compile indeed now. Can test tomorrow if the .apk still works.
The useless warning has been removed - https://github.com/iBotPeaches/Apktool/commit/3264f142cbfbf7c20a103ee33823ced5d5cccb10
The malformed 9patch image is probably the same image referenced in this ticket - https://github.com/iBotPeaches/Apktool/issues/1559
I think this is actually a duplicate of #1157 , but I need to research it more to make that connection
The malformed image is easily fixed. Usually though if apktool doesn't have the resources to compile then it should not have decompiled in the first place? usually if a large set of ids aren't defined then you can trace it to one mistake. There is no error in that folder. you can even delete the bad images and apktool will not recognize that as an issue. Does this need to be defined in the manifest? the ^attr-Private?
Any progress on the ^attr-Private issue? :)
Malformed 9 patch is easy to get around
Double penalty for asking such a question, since you are a dev yourself :o)
Bwuhahaha... Been trying to bend my head around it.. penalty accepted, i see you managed to compile :)
framework.apk has ^attr-Private xml file and ids too after compiling, but can be recompiled. @iBotPeaches
^^^ this ^^^. framework-res.apk has the ^attr-privates.xml and there is no issue decompiling and recompiling. There is only one translation warning which has nothing to do with this issue.
So there is more going on here. Obviously apktool has the resources to deal with this new xml.
Two solutions have developed, SystemUI can be recompiled after modifying by both of them.
can you post the solution?
Will develop a tool to solve this.
Removed
Jan this is Java source. Have you created an app for this?
Thats c#
my bad just glanced at it. how does this solve this?
Read the code, Lol.
https://www.dropbox.com/s/2haxs9ckdn0696h/PrivAttributesFixer.exe?dl=0
so you are renaming the files. I tried that and it didn't work lol
Well, you need to do more than that you need to rewrite the public.xml. give the renamed attributes new ids incremented by the highest original attribute id. Then replace the old ids with the new ones in the smalis too
Thanks. It looks like this tool also changes smali code. Just put all the files in one folder with the tool?
...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.
Thank you.
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.
Okay, research on this is a stand still. I didn't discover anything more, I'm going to work on something crazy and that is #1689 (which is moving to aapt2
). More and more applications are built (by default in Android Studio) in aapt2
, then decoded by Apktool and attempted to be built in aapt1
.
I need to keep patching aapt1
which is proving to be difficult as shit, especially when your low level knowledge of the AOSP build system sucks. Moving dependencies to be static, forcing 32 bit builds etc is not knowledge I have for AOSP.
I fear one day aapt2
will become the only solution and aapt1
no longer functions. I am starting the long, slow battle to moving to aapt2
and hoping this will be resolved when I solve that.
So we get a different failure in aapt2
W: brut_util_Jar_7457333169979251814.tmp F 04-11 16:50:17 12878 11417869 PrivateAttributeMover.cpp:84] Check failed: priv_attr_type->entries.empty()
I can remove this check and rebuild aapt2, but it must be there for a reason. I'll do some digging.
Thanks for your persistence with this one @iBotPeaches , its quite frustrating! 👍
Seems like using AAPT2 was not necessary here. File: frameworks/base/tools/aapt/ResourceTable.cpp Function: status_t ResourceTable::assignResourceIds() Change:
if (mPackageType == System) {
p->movePrivateAttrs();
}
To:
p->movePrivateAttrs();
This allowed the APK to be recompiled, and another decompile resulted in the same resources, so seems to work fine.
Seems like using AAPT2 was not necessary here. File: frameworks/base/tools/aapt/ResourceTable.cpp Function: status_t ResourceTable::assignResourceIds() Change:
if (mPackageType == System) { p->movePrivateAttrs(); }
To:
p->movePrivateAttrs();
This allowed the APK to be recompiled, and another decompile resulted in the same resources, so seems to work fine.
Do you have the aapt.exe file that is modified to do this that you can link a download to by chance?
Do you have the aapt.exe file that is modified to do this that you can link a download to by chance?
Nope.
@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.
@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
@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.
Perhaps I'll try to make a pull request with my own fixes that make resource compilation more confident.
@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#L224Can 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 ?
@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#L224Can 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
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
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
Anyone? @iBotPeaches
Please use new ticket. This is 2 years old and I'd prefer to have a new issue with the template filled out for triage.
@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#L224Can 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
So, this already included in latest apktool version 2.9.3
?
The new issue is something like this:
W: D:\source\.\apk_bb\res\values\public.xml:634: error: no definition for declared symbol 'com.jilrew.bb:^attr-private/el_contentLayout'.
W: D:\source\.\apk_bb\res\values\public.xml:635: error: no definition for declared symbol 'com.jilrew.bb:^attr-private/el_duration'.
And it's a application(not system) level app.
Information
apktool -version
) - 2.3.0Stacktrace/Logcat
Steps to Reproduce
apktool
d SystemUI.apkFailes loading resources?
Had first to delete the .9 suffix to from all pip_dismiss_scrim.9.png because of:
then apktool b SystemUI brings the not found attributes warnings/errors
files.zip