setContentView shows number; how can I find layout after decompile code?

南楼画角 提交于 2019-12-11 09:43:57

问题


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.


回答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.




回答2:


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.



来源:https://stackoverflow.com/questions/34082661/setcontentview-shows-number-how-can-i-find-layout-after-decompile-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!