iBotPeaches / Apktool

A tool for reverse engineering Android apk files
https://apktool.org/
Apache License 2.0
19.76k stars 3.56k forks source link

No resource found that matches the given name '@android:style/APKTOOL_DUMMY_2df'. #2339

Closed MaroX97 closed 4 years ago

MaroX97 commented 4 years ago

Information

  1. Apktool Version (2.4.1) -
  2. Operating System (Windows) -
  3. APK From? (ApkPure) -

Stacktrace/Logcat

I: Using Apktool 2.4.1 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: C:\Users\Marven\Desktop\NKS\AppGallery\res\values-v24\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name '@android:style/APKTOOL_DUMMY_2df'. W: W: C:\Users\Marven\Desktop\NKS\AppGallery\res\values-v24\styles.xml:8: error: Error retrieving parent for item: No resource found that matches the given name '@android:style/APKTOOL_DUMMY_2de'. W: brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\Marven\AppData\Local\Temp\brut_util_Jar_15689651341875386559.tmp, p, --forced-package-id, 127, --min-sdk-version, 21, --target-sdk-version, 28, --version-code, 100201300, --version-name, 10.2.1.300, --no-version-vectors, -F, C:\Users\Marven\AppData\Local\Temp\APKTOOL13289399724538177059.tmp, -e, C:\Users\Marven\AppData\Local\Temp\APKTOOL1812228349152951016.tmp, -0, arsc, -I, C:\Users\Marven\AppData\Local\apktool\framework\1.apk, -S, C:\Users\Marven\Desktop\NKS\AppGallery\res, -M, C:\Users\Marven\Desktop\NKS\AppGallery\AndroidManifest.xml]

Steps to Reproduce

  1. tried decompiling then compiling without any changes i got

No resource found that matches the given name: attr 'android:pointerIconWait'

2.used Huawei P8 framework-res.apk (downloaded from here ), i got the error i'm posting above

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. https://apkpure.com/huawei-appgallery/com.huawei.appmarket/download

Questions to ask before submission

  1. Have you tried apktool d, apktool b without changing anything? yes i do
  2. If you are trying to install a modified apk, did you resign it? --
  3. Are you using the latest apktool version? yes
Ticklefish commented 4 years ago

If you get APKTOOL_DUMMY that's generally because apktool can't decode some of the information in the original APK and creates a 'dummy' value instead. Because there's no style called APKTOOL_DUMMY in public.xml (which essentially lists all the resources in the app) the APK can't be recompiled.

It's worth using a program like Notepad++ and searching the decompiled files for every style defined in public.xml. In theory, there should be two there that aren't used in any other XML files. Those should be the ones that the APKTOOL_DUMMY values are referring to. If you know which those are, you should be able to rename them in public.xml and styles.xml. Then your file should recompile. Hopefully.

iBotPeaches commented 4 years ago

@Ticklefish - close, but in order to check that you normally need to dump the resources with aapt, with something like

➜  2339 aapt d resources Huawei\ AppGallery_v10.2.1.300_apkpure.com.apk | grep 'INVALID'
➜  2339 

There are no results, so the reason that dummy attribute came to fruition, must be different. I ran in verbose mode -v to see if anything stuck out and I spotted.

Jun 28, 2020 7:51:52 AM brut.androlib.res.data.value.ResStyleValue serializeToResValuesXml
FINE: null reference: m1=0x011200a9(reference), m2=0x7f040233(reference)
Jun 28, 2020 7:51:52 AM brut.androlib.res.data.value.ResStyleValue serializeToResValuesXml
FINE: null reference: m1=0x01010540(reference), m2=0xffffffff(bool)
Jun 28, 2020 7:51:53 AM brut.androlib.res.data.value.ResStyleValue serializeToResValuesXml
FINE: null reference: m1=0x01010540(reference), m2=0xffffffff(bool)

You can tell those resources start with 0x01 (or a framework resource).

So @MaroX97 what is happening is Apktool is trying to find a framework source for the styles class that is cannot find. When this happens there is literally nothing Apktool can do. I've debated putting in AOSP resources directly into Apktool to maintain pkgId 1 resources, but as you can see with the hundreds of flavors of Android - that would not be feasible or correct.

There is no bug here, arguably Apktool could die out here and instruct of missing resource, but I don't want to break execution for something that may happen.