Jayesh
Jayesh

Reputation: 3881

How to get the R.java file when decoding apk file?

I just decode one apk file, but issue is that I can't get the R.java file.

The R.java file is created automatically in the application, but when the apk file is decoded, it gives the hex value that is created in R.java instead of @string/abc or @color/white etc ....

When we create string or color or any other resources in the application, android platform assigns some hex value to that string or color in R.java, so when we decode the apk file, it gives that hex value, so how can we decide that particular hex value is for that string or color ?

Upvotes: 3

Views: 4394

Answers (3)

Phani
Phani

Reputation: 131

You cannot directly extract r.java file, but the contents of r.java file can be extracted using 'aapt' tool. The following command lists all resources and their respective ID's as present in r.java file:

aapt d resources name_of_apk

Upvotes: 11

Nirav Ranpara
Nirav Ranpara

Reputation: 13785

Download android-apktool , extract all in the same directory and run

apktool d app.apk

Upvotes: 2

Ted Hopp
Ted Hopp

Reputation: 234795

The R class consists of nested classes, each of which consists consists entirely of compile-time constants. If the .apk file was obfuscated by ProGuard (which will be true of pretty much all published apps), all this will have been optimized away. There's no way to recover it.

Upvotes: 3

Related Questions