Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
matching android views xml ids to java
#1
Hello, I'm new in RE. I'm searching for tools to decompile apk finding the link of android views xml ids to java code and cannot find. Are there such tools that link Android views as described in layout / xml files to findviewbyid methods in java code?

Java machine somehow does that during execution. Why I get like android:id="@id/textView1" in xlm and findviewbyid (3523423) in java in Bytecodeviewer? (I just started by use Bytecodeviewer and upon opening apk it produces such output - maybe there is some trick to match ids?).

Thanx!
Reply
#2
(03-10-2016, 08:29 PM)AlexM20 Wrote:  Why I get like android:id="@id/textView1" in xlm and findviewbyid (3523423) in java in Bytecodeviewer?

When developing an android app the buildsystem generates a class called R.java which holds all references to stuff defined in resource files (like xml files) in static members. The compiler is able to eliminate all references to the R.class by directly using static values defined in this class when building the apk. This is why you just see calls like findViewById(0x1234567Shadehappy after decompilation. The mapping between identifiers and static values gets saved in the compiled resources file resources.arsc.

I would suggest you use apktool (http://ibotpeaches.github.io/Apktool/) to get the link between identifiers and layouts. apktool is able to generate a xml file which holds the needed information from the compiled resources. You can find all identifiers in a file called public.xml in <targetapp>/res/values/public.xml after decompilation.

Just as an example: activity_layout.xml
Code:
...
<ImageView android:id="@id/oneupDrawable" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="80.0dip" android:src="@drawable/oneup" />
...

public.xml
Code:
...
<public type="drawable" name="oneup" id="0x7f020045" />
...
<public type="id" name="oneupDrawable" id="0x7f0c0053" />
...

activity.smali
Code:
const v4, 0x7f0c0053
invoke-virtual {p0, v4}, Lde/some/app/activity;->findViewById(I)Landroid/view/View;

Hope that will help you!
Regards, mik
Reply
 


Forum Jump:


Users browsing this thread: 2 Guest(s)

About The Bytecode Club

We're a community forum focused on Reverse Engineering, we try to target Java/Android but we also include other langauges/platforms. We pride ourselves in supporting and free and open sourced applications.

Website