1

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.

kapilgm
  • 1,620
  • 1
  • 15
  • 22
Rahul Vats
  • 277
  • 3
  • 17

2 Answers2

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
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