[Go] Combine hierarchyviewer and apk file decompile to get the app element ID value

Source: Internet
Author: User

Background: Android Automated testing was recently performed using Robotium. A problem has been encountered: I need to get a view ID (int type value). I have previously described how to open the view on my phone in two articles in http://maider.blog.sohu.com/255448342.html and http://maider.blog.sohu.com/255485243.html Server to use Hierarchyviewer. Hierarchyviewer is helpful for viewing UI components, but it is not possible to get the ID of an element. See: I see "release" in Hierarchyviewer this view,hierarchyviewer shows a @414a54c8And id/flipper_head_action。Note: Adding a string of 16 digits after @ is not the ID of this view, but a pointer value that does not make any sense to us humans. But we have the ID name of this element.flipper_head_action. We need retrace to find the corresponding value by this ID name. steps to resolve:1. Download the anti-compiler Dex2jar, and a Java source viewer Jd-gui: https://code.google.com/p/dex2jar/downloads/detail?name=dex2jar-0.0.9.13.zip&can=2&q=https:// code.google.com/p/innlab/downloads/detail?name=jd-gui-0.3.3.windows.zip&can=2&q=2. Unzip the first step to download something and put it in the appropriate folder. 3. To the anti-compilation of the apk file suffix to zip and unzip, get the Classes.dex, it is the Java file compilation and then through the DX tool packaging, the classes.dex copied to the 2nd step extracted by the Dex2jar.batThe folder where you are located. 4. Position the command line to Dex2jar.batin the folder where you run the command: Dex2jar.bat Classes.dexBuild under the same folder: Classes_dex2jar.jar5. Open the second step to extract the resulting Jd-gui.exe, file-"Open File opens fourth step of the generatedClasses_dex2jar.jar6. Now in the left navigation in Jd-gui, navigate to the package where the app is located! (This is the package name you can see in the Hierarchyviewer). Example diagram:
7. Scroll Jd-gui to the lower left navigation bar to see the anti-compiled R file. And one of the r$id is the file we're looking for. 8. Now, in the R$id file, search for the element ID name that this article has started with (flipper_head_action), we get the ID of this element with an int value of 2131427472. Done!  This article references: http://blog.csdn.net/sunboy_2050/article/details/6727581

[Go] Combine hierarchyviewer and apk file decompile to get the app element ID value

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.