-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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] Can't compile WhatsApp: No resource identifier found for attribute #3129
Comments
Lost at the moment as we have (what I thought was) the latest Whatsapp crashing before even getting the point of reassembly in this issue - #3036 |
Hi, thanks for your response. I did reproduce #3036 and it does only happen with the WhatsApp version mentioned in this issue (2.23.8.4), which is outdated. Updating to the most recent version fixes the issue. |
@iBotPeaches is there any update in this ,plus i downloaded the source code of the apktool trying to find the issue and fix it is there any docs or hints on where i can find the issue which part of code or do i need to read the whole source code to figure it out :/ btw after updating my apktool do i need to decompile the apk again or can i compile the one i used the old apktool version decompiled i don't know if it makes any errors or something |
@byomi - This repo has had more activity from myself in the past 2 weeks than the last 4 years combined - so yes plenty of updates, but nothing for this ticket. The best hint I have is looking at the AXML parser between the namespace association and how it handles with value comparisons between the string pool and resource table. Its always good behavior to decode an application again with a newer apktool in case it was decoded improperly prior. |
@iBotPeaches thank for the hint i see after quite time of search i found that the issue is i need to add this 2 lines to the attrs.xml
still didnt figure out what part of the code does this job but i get this soultion for now but still failed to build with this error not quite getting why this error happens i removed the line but still got other errors @andrewille here a fix for the errors for now add these 2 lines to attrs.xml and if u get the error in androidmanifest just delete the lines if i found anymore solution i will update u with details |
Thank you so much for sharing this! After updating to ApkTool 2.8.1 and applying your fix to the attrs.xml I can compile it without any problems! I haven't installed it to my device yet, but I think it should work fine. |
@andrewille it should work fine but let me know if u can register in whatsapp normaly test it i tried change package name but idk it says problem with whatsapp idk if its the package name it self or it verify signature can u test it and tell me what comes up with u @iBotPeaches if an apk crashes after compile and sign it or just show corrupted installation after just decompile and build does it cause because the app protected from sign with different key and if it is i searched alot on how t bypass but there is no good guide for that or info about what is the thing i need to search any help will be appreciated (ik its out of the ticket body but i hope anything could help me ) finally thanks alot |
I have never tried to re-register using one of my custom versions. My phone is rooted and I use a backup App (Swift Backup in my case) to restore the App's data after installing my modded version. This way WhatsApp would think you just updated the App and you don't have to register (again). So if your phone is rooted, just restore the data. If not, then you probably have to figure out what they do and how to bypass it, which might be much more complicated than just removing a small part of the code. Good luck tho! |
@andrewille oh ok i got my answer so whatsapp working fine with u hmm looks like its package name issue which make my whatsapp not working thanks for info ,nah my phone not rooted and actually i am not gonna like uninstall and install whatsapp million times everytime i change something or else ,anyway thanks and have a nice day. Note: i remember lets say a new version of whatsapp cameout and this outdated mod need an update how do i update my mod do i rewrite the files to the new apk or what u have anyideas? |
Glad that it worked for you!
If you need to update to a newer WhatsApp version, you have to decompile the latest WhatsApp Apk, then apply all of your changes again to the new version (you may need to change different things as they might change the structure of their code/resources). Then you can build and install the new modded Apk just over the old one on your phone. You do not need to uninstall it before as long as you use the same signature. This way you also keep all your app data. |
@andrewille ok thanks alot i appreciate that one more question how does these modded whatsapp change the package name to install it side by side with other version or any another app not only whatsapp do u have any idea? |
I have never attempted to rename it, but you could try to set a different name in the apktool.yml. Change renameManifestPackage inside packageInfo to a string with a different name. But as I said, I never tried it so idk if it works. Maybe there's a simpler solution, but I think I can't help you with it |
@andrewille but how u install it on the old version when u cant sign your build with a different key?? and i just found that if i signed whatsapp it fails registeration because it says problem with whatsapp install from playstore and if i did as u said the original then my build i cant install it because its signed with different key so how u do it? |
Maybe I misunderstood you. I thought you got it working now and you can register. Of course you can only install your apk over an installed version if it is signed using the same key. You will never be able to sign with the same key that original WhatsApp uses. You have to create your own one and sign with it. I just meant that if you had it running once, signed with YOUR key, then you can easily update the mod and install it over YOUR old versions without having to register ever again.
As I said, I never faced that problem because I backup everything, then uninstall WhatsApp and install my mod and then I restore only the data. This way I never have to register again and everything just works. This is what I meant when I said they may have a protection. I don't know what they do exactly, but it comes down to three ways they could have achieved it:
It might be the easiest way to just root your phone and do the same as I do. Another hacky way I can think of is to get (the original) WhatsApp running in an emulator or someone else's rooted phone, then backup the data and then package the app data right into your mod (or make it restore it at the first start). This way you should be able to keep your session and be logged in on your phone, without another registration. In the end, the registration is the point where the protection is in place, so you have to bypass the protection itself or get around the registration. I use the second way and it's much simpler. |
@andrewille i am using emulator now which is rooted so basicaly u backup it then restore oh so u didnt register in your mod before u just restore it which instantly get u to chat ok i get it now i thought u install your mod on the original whatsapp ok thanks .(when it comes to hardcoded i have np i like to learn) btw do u recommended any java decompilers like jadx its kinda heavey i dont want to use it do u have any? |
Yes, exactly.
I actually like JadX (the graphical program) and use it often. You could also try Bytecode Viewer, which has multiple decompilers built-in. But I think this one uses much resources too. |
@iBotPeaches I ran into the same problem with the version 2.8.1 and the latest version of whatsapp from their website, 2.23.17.73. When decoding the named animators those attributes come from the app xmlns. apart from the 4 animators mentioned in the log, there is another one (0x7f020000) that has the namespace, but the resource asked appears in the java code too, maybe that's why they appear in the attrs.xml, and the state_dragged or state_with_icon doesn't. In brut-apktool/apktool-lib/src/main/java/brut/androidlib/res/decoder/AXmlResourceParser.java the function decodeFromResourceId generates an exception that is ignored, caused because the mResTable doesn't have the ResSpec for the id 2130970312 (state_dragged). After this ignored error the attribute comes named as they normally came (state_dragged) but I believe that by the time of compile is not finding in any res table. That's why adding to the attrs.xml works (I have also compiled like this and fixed the problem). I didn't fully understood the creation of the resource tables, to understand better why the package app doesn't have this resource in their list, but I hope to have contributed in finding the solution faster. The exception being raised: |
I can see the exact same behaviour in this thread happening on Pixel 8's AiWallpaper. Except, it also happens for more attributes other than |
@linuxct - Attributes/properties did have some flaws. Upcoming release takes an aim at many of those: Just waiting on AOSP Android 14 sources to add the new qualifiers and I'll release 2.9.0 |
Got it, thanks a bunch! I was running the latest build from master as of a week ago, so I should have those changes in my local build already. Will wait for your release with Android 14 fixes regardless before proceeding |
Hey again, congrats on the 2.9.0 release! I have tried again to decompile and then rebuild the Google AiWallpapers APK that's floating around lately, and it still wouldn't work (clean frameworks dir, or using an Android 14 Pixel's framework). I figured maybe it'd be useful to send you the file to see if you can reproduce it? The issue seems similar to the one in this thread, except the attributes are "known" ones, as I was saying the other day... or perhaps the OP can be rewritten to make it clear it's not just WhatsApp that's affected by this issue |
Okay, lets take a look at this application again and see whats going on. Start with the error that I replicate.
So lets check if that attribute exists.
So the issue is apparent - we are referencing an attribute that we did not disassemble. However, it could be there under a different name, so lets further investigate. We want to ask aapt2 what it thinks about this file, but going from the name of the file - its name has been stripped. So first lets reverse that lookup either using apktool verbose mode or aapt2.
So we know we want the file
The name is preserved (
No results :/ So that explains the error. The only option I see here is making the disassembler a bit greedier and remove attributes if we cannot resolve, but thats also a can of worms. So this will probably sit a bit - unsure on path forward. |
@iBotPeaches Apparently the root cause of these resource issues is resource shrinking optimization. It removes unused resources after optimizing app code which is why they seem to be missing / are missing. These resource shrinking is getting used by more and more apps lately and even most of the AOSP seems to have been migrated to use this shrinking in udc. To test this I compiled same Traceur app from AOSP with and without commit [1]* and then tried recompiling them using apktool. res\animator\mtrl_card_state_list_anim.xml:4: error: attribute state_dragged (aka com.android.traceur:state_dragged) not found. The resolution I can think of about this is adding a flag or something for ignoring or removing the missing attribute outright as done by optimization in first place likely suggested by you above . But since the cause is now known I guess you can now think of better solutions. Test APKs: |
Hi andrewille how do you back up eveything? I tried then copying full content of /data/data/com.whatsapp and had some issues with permissions and with /data/user/0/com.whatsapp I then tried copying that folder also and setting the correct permissions but now I have this exception when I uninstall the oficial apk and install my version:
I also noticed that when app is uninstalled it will remove the permissions:
Do Iahve to then modify the apk to request this permissions first thing? |
Hi @gcandrade10,
I just use Swift Backup to backup and restore the app's data as well as media. It will take care of the permissions and will also restore runtime permissions (the ones you have to accept like accessing your contacts etc).
Your errors say that you have not properly set the file permissions. Android creates a separate user for every installed app. If you would really want to do it manually, you would have to find out which user was created for WhatsApp. You can find it out with That said, I would not bother with doing this manually cause you can have it way easier as I wrote above.
This is about Android runtime permissions. Don't confuse it with file permissions. Those runtime permissions were declared by WhatsApp and are removed globally therefore if you uninstall it. This does not break anything, it is just fine. |
Hey @andrewille I owe you a beer, it worked like a charm! thanks! |
any updates on this issue? |
any updates? |
Information
apktool -version
) - 2.7.1-2b8121-SNAPSHOT (also tried 2.7.0)java --version
) - openjdk 11.0.19 2023-04-18Description
I tried to re-compile WhatsApp, but this time I get the following errors. It worked for years, but now they seem to have changed something with their resource packer. The unpacked files are correct though, JADX is giving me the same XMLs. I found the issue #1663 that seems to be a duplicate, but I got confused about the answers, just like some others in the comments.
Why does this happen? Does the attribute have a different, obfuscated name that I can find out and replace manually?
Stacktrace using aapt1:
Stacktrace using aapt2:
Steps to Reproduce
APK
WhatsApp 2.23.12.78 from Google Play Store. I'd rather not re-upload it for legal reasons.
Questions to ask before submission
apktool d
,apktool b
without changing anything? YesThe text was updated successfully, but these errors were encountered: