1

How does R.java work? In a compiled .apk file, does it contain all constants from the XML files prior to compilation? I've decompiled an app using several Java RE tools, and used apktool to extract the resources (xml files, images and others). However, when rebuilding the project in Eclipse, the R.java generated by Eclipse (in the gen folder) does not match the original R.java from the decompiled app. Is this a common occurrence when reversing android apps? In this case, the original R.java contains fields consistent with the rest of the code. However, this is not present in the generated R.java and hence this error.

The decompilers I used are

1) JEB (Commercial)

2) jadx (Open-source)

enter image description here

3
  • why the downvote?
    – Nederealm
    Commented Oct 15, 2014 at 18:49
  • 2
    Could you clarify what's the question?! I see two sentences with a question mark, but neither has a lot to do with reverse engineering.
    – 0xC0000022L
    Commented Oct 15, 2014 at 19:18
  • Ok, I reworded the question. Hope it's clearer to understand
    – Nederealm
    Commented Oct 16, 2014 at 4:18

1 Answer 1

1

The R.java file created by jadx exists to be a reference between the resources id after compilation and the name of the resource mentioned throughout the code.

If you wish to recompile it, it is possible to recreate something that looks like the original xml files by creating a script that ignores a part of the prefix and searches for the resource's name. Once it is located inside the xml files, specify the correct one.

And I think that apktool provides a much better reference to the resources xml files.

But if what you wanna do is make just a small change, it will be faster to do it with smali and use apktool to put it all back together again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.