Android Confusing Basics

Source: Internet
Author: User

Website Description: Https://www.guardsquare.com/en/proguard/manual/introduction

Android Development Documentation: Https://developer.android.com/studio/build/shrink-code.html

1. The basic principle of confusion

The confusing principle of the Android platform is simply to replace the name of the package name, class name, variable name, method name, and so on in the code with the meaningless English letters A, B, c ... so that the code structure does not change, you can run the same results, and even if the code is recompiled , it is difficult for others to understand the structure and specific meaning of the code.

2. Obfuscation steps

A. Open
Minifyenabled  is True

Buildtypes {
Release {
True
Proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' Proguard-rules.pro '
}
}

customizing files in B.android Studio
Custom in the file engineering \app\proguard-rules.pro.
Do not confuse the custom public print function in the ScrollView class
-keepclassmembers class Com.example.zcx.democoderjoy.ScrollViewActi {
public *;
}
Effect: Add previous decompile:

Home After Effects:

found that the print function was added, and was not confused.

C. Proguard will output the following files each time it is built:

dump.txt
Describes the internal structure of all class files in the APK.
mapping.txt
Provides conversions between raw and obfuscated classes, methods, and field names.
seeds.txt
Lists classes and members that are not confused.
usage.txt
lists the code that was removed from the APK.

These files are saved in the <module-name>/build/outputs/mapping/release/

3. Confusing pros and cons

The advantages of confusion are mainly two: 1. Optimize the deletion of useless code, reduce the size of the APK. 2. After confusing the code to decompile it, it is impossible to understand the specific content.

Cons: Debugging is inconvenient (you can use Mapping.txt), and testing may not be sufficient to cause some features to be disabled.

    • Debugging inconvenient (can be configured mapping becomes convenient in the path)
    • Insufficient testing may result in some functions not being used (such as annotation correlation, etc.)

Android Confusing Basics

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.