Android Obfuscation Summary (ii)

Source: Internet
Author: User

Ⅰ. Preface

The previous article summarizes the confusion related knowledge points, the basic technical points are listed. If the project development is more tense, you can consider applying a confusing configuration template, copying and pasting the base and then tinkering with it. The previous article talked about and friends to discuss the problem, the first few days have been basically explored, then also have to rationale ~ summed up, expect more problems to appear ~ before you can go to explore.

Ⅱ. Exception Collection

The main technical point of this article is the exception collection, the project before the launch in addition to confusion, packaging, reinforcement, signature and release, there is an inevitable, is the application of a variety of statistics, the application of various statistics including abnormal collection statistics, the application of the channel download rate, active volume, Retention rate and page access statistics and so on, there are many third-party statistical SDK for access to use, such as friends of the League +, Baidu, GE IO and other third parties, fine points can be considered under the non-embedding technology. As long as the integration of the statistical SDK before the launch, then in its corresponding background to see the various data after the statistics report.

Statistics for operations and project maintenance is very necessary, developers can see the exceptions collected, and then analyze the exception and find the corresponding solution, then this is the topic of the article, the following is the friend Union + background collected by the exception information, The phone model, version, and channel where the exception occurred can also be collected under its exception information. Look at the abnormal information, when you see the red circle out of the part, is not confused, the exception information how there will be ABC such a substitute, the exception information can let developers know where the anomaly occurred, can make it easy to locate, but now? Difficult to guess the way to locate the anomaly, That's it. No wonder friends say that the problem of abnormal information is very confusing, then the following began to the whole confusion.

Ⅲ. How to restore confusing information

For the above exception information appears ABC substitution, mainly because of confusion packaging caused by the above ABC is actually the project's class name or variable name substitution, then if the APK is not confused will cause the APK source code leakage or two times packaging, although the confusion after the APK is still a big risk of leaking, However, the difficulty of code leakage is increased, so confusion is indispensable. So how do the above exception information position the bug?

The Android SDK Toolkit provides the tools to solve the Sdk\tools\proguard\bin path named "Proguardgui.bat" and "Retrace.bat" (under Windows and Linux, the tool's suffix name is different) Two tools, the former is a graphical way to decompile the confused exception information, the latter through the command line to the confusing exception information is compiled. Then before using this tool, there must be a file called "Mapping.txt", see below, this is a file generated after the package apk is completed , it mainly records the information mapping relation before and after the confusion.

Every time the APK is finished, the generated mapping.txt is necessary to save, how to use the above mentioned "Proguardgui.bat" and "Retrace.bat" two tools? See below can, simple fix proguardgui.bat, but sorry is I tried a lot of times, can not transform the exception information back, and the most non-language is the search to the article introduction of the method and I operate exactly the same, at this time I found often encountered the wonderful problem, The basic article shows that the exception information is the same, such as these articles are copied , the Android SDK provided by the "Proguardgui.bat" graphical tool has been invalidated, and then try the "retrace.bat" tool. It also mentions " Proguardgui.bat "and" Retrace.bat "the two tools are basically the same, but the use of different ways, one is a graphical way, one is the command line mode.

To decompile the exception in the Retrace.bat command-line tool, the instruction used is

格式:retrace.bat|retrace.sh [-verbose] mapping.txt [<stacktrace_file>]例如:retrace.bat -verbose d:/mapping.txt d:/wyk_stacktrace.txt

Then verify the command line form of "Retrace.bat", and different from the above Proguardgui.bat tool has a panel can paste error messages, so first save the exception information as a TXT file, and then the command line into the Android SDK storage path Sdk\ The Tools\proguard\bin directory, which is entered according to the instruction format above, results in the following:

Conclusion: The "Proguardgui.bat" and "retrace.bat" kits cannot restore the confusing exception information on the APK line.

Above is the result of using the "Retrace.bat" Tool's anti-compilation exception information, you can see that the ABC identifier still exists, so the complete exception information is still not available. Anti-second interview a lot of times, still no fruit, or look for there is no other way it ~ ~ in the Android SDK Sdk\tools\proguard\lib directory has "Proguardgui.jar" and "Retrace.jar" the two jar package, The "Proguardgui.bat" and "retrace.bat" tools used above may be based on these two jar packages, and consider whether there is a solution if the two jar packages are used directly to try to decompile the exception information. First try Retrace.jar This jar package, the command line into the directory where the Jar is located, enter the command line as follows, the output information and the above Retrace.bat tool output, there is still no complete exception information.

格式:java -jar retrace.jar [-verbose] mapping.txt [<stacktrace_file>]例如:java -jar retrace.jar -verbose d:/mapping.txt d:/error.txt

Then try Proguardgui.jar, command line into the directory where the Jar is located, enter "Java-jar Proguardgui.jar" start Proguard tool, see the interface and Proguardgui.bat is the same, It should be said that the Proguardgui.bat boot is also this jar package, after the validation still did not get complete exception information.

Conclusion: The two jar packages "Proguardgui.jar" and "Retrace.jar" cannot restore the confusing exception information on the APK line.

Ⅳ. Verifying against Mapping.txt files

The above tool can restore the confused exception information, Its principle is because the mapping.txt existence of its confusion before and after the mapping information, it is not possible to find the corresponding mapping in the Mapping.txt file based on the confusion of a small segment of the exception information, copy the confusion of the exception information in the Mapping.txt file for full-text search, the following figure 1 is collected in the statistics of abnormal background information , Figure 2 is the mapping information in the Mapping.txt file to find the red circle portion of Figure 1. Figure 3 is also the exception information and mapping relationship.

Conclusion: The mapping relationship between the above abnormal information and the corresponding APK and the generated mapping.txt should be saved, which will play an important role in the tracking and maintenance of the bug after the on-line. Ⅴ. Other ways to restore confusing exception information

The above based on Mapping.txt find information mapping relationships, obviously not suitable for online bug tracking and application maintenance, so you have to find another export, often used to the statistical Anomaly SDK has friends and bugly, has been in the UF League + statistical Anomaly SDK, Since the statistical data is not timely and omissions, so the application of the choice of access bugly,bugly for the exception of the collection is very timely and accurate.

These statistical anomalies of the SDK in fact provide the ability to restore the confused exception information, so that the developer is very friendly, the location of the SDK in the background of the exception information, only need to import the exception information corresponding to the application version of the mapping file, click the "Resolve" button to see the original exception information.

In the Friend League + statistics Backstage Pro-test found that the abnormal can not be reduced to restore, explored several times still can not find the reason. In bugly, the statistics Background Pro test is effective, you may see the following confusing exception information and after the restoration of the exception information.

Ⅵ. Summary
    • App line anomaly Tracking, you can choose Friends League +, Baidu, GE IO and other third parties, fine points can be considered under the non-embedding technology;
    • It has been tested that the "Proguardgui.bat" and "Retrace.bat" packages of the Android SDK package cannot restore the confusing exception information on the APK line;
    • The mapping file generated after the APK package holds the mapping relationship before and after the code is confused;
    • The statistical background of the third-party SDK generally provides the ability to restore "confused exception information";
    • Remember to save the APK version and the generated mapping.txt when you pack.

This chapter summarizes the points, there is wrong place, please correct me.

Android Obfuscation Summary (ii)

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.