skylot / jadx

Dex to Java decompiler
Apache License 2.0
40.02k stars 4.73k forks source link

[core] Cannot reconstruct resources' references #1673

Open JohnFarl opened 1 year ago

JohnFarl commented 1 year ago

The decompilation generates integers for the resources without proper mapping e.g.

this.mRefreshItem.setIcon(17301629);

I have tried to convert this 17301629 in HEX the result is: 0x108007D to search the matching in public.xml that associates hex values to resources names, without finding any matching

If I try the option export mapping it generates empty files.

The option Better resource seems totally ineffective and despite it is set on RESOURCE mode I continue to get such numbers rather than a clear matching

The apk I have tried link.

I'm using latest Jadx 1.4.4

jpstotz commented 1 year ago

17301629 respectively 0x108007D is a resource constant defined in the Android framework, so you won't find it in the APK itself.

We already have this constant in our combined resource lookup table that covers most Android framework resource names: 0108007d=drawable/stat_notify_sync_noanim

But we don't replace global resource constants in code, only constants from fields of classes that belong to the current app (like the R.class. But is seems possible to also use constants from Android resources.

So instead of 17301629 or 0x108007D we could use the constant android.R.drawable.stat_notify_sync_noanim.

JohnFarl commented 1 year ago

@jpstotz Thanks for the info, would be very useful if Jadx replace automatically these entries... however, what is the combined resource lookup table you are talking about that I could use to understand to what resource belongs each integer?

jpstotz commented 1 year ago

@JohnFarl This is the combined resource lookup table we use in Jadx: https://github.com/skylot/jadx/blob/master/jadx-core/src/main/resources/android/res-map.txt

It had been generated from all the Android.jar files (all Android API versions) available at that point.