I have decompiled an apk code by using apktool. The code which I got contains setContentView(2130903087); My question is how can I find the layout name from this line.
Asked
Active
Viewed 1,516 times
1
-
If you have R.java file, search for the id with this value. thats the view/layout you require. – VINIL SATRASALA Dec 04 '15 at 07:16
-
There is no R.java file. Then tell me how I proceed. – Rahul Vats Dec 04 '15 at 07:51
2 Answers
1
At first convert this decimal number into hexadecimal. Then,after decompile the dex file, you will get R.java file inside your decompiled code. In that search for the hexadecimal number, you will get the layout file.

Nigam Patro
- 2,760
- 1
- 18
- 33
-
HI Nigam. There is no R.Java file under gen folder, there is only BuildConfig.java. Please tell me how I proceed. – Rahul Vats Dec 04 '15 at 07:49
-
-
-
There is no file under src folder. This folder is empty. But as you said I convert the number to hex. Then I search the string in the whole project its showing a activity name in public.xml (under res/values/public.xml). Is this correct? – Rahul Vats Dec 04 '15 at 08:00
-
1
Apktool uses smali to disassemble applications. The code line you wrote was not produced by apktool.
Lets take an example application and decode it. (apktool d test.apk
). Then lets peek at a file that we know is using setContentView
.
const v0, 0x7f040037
invoke-virtual {p0, v0}, Lcom/android/deskclock/Screensaver;->setContentView(I)V
As you can see. v0
is populated with the hex equivalent of the resource id of the layout. So now we just need to grep
for that ID.
res/values/public.xml: <public type="layout" name="desk_clock_saver" id="0x7f040037" />
So now we know that layout was desk_clock_saver
. So we can peek in res/layout
for it.
ibotpeaches@relic:~/test$ file res/layout/desk_clock_saver.xml
res/layout/desk_clock_saver.xml: XML document text
There we have it.

Connor Tumbleson
- 3,270
- 2
- 25
- 37