Android code obfuscation

Source: Internet
Author: User

Android code obfuscation involves Proguard, which is an open-source java code obfuscator. Its function is as follows:

1. Create compact code documentation for faster network transmission, fast loading, and smaller memory usage

2. It is difficult to use reverse engineering to create programs and libraries.

3. Therefore, it can delete code not called from the source file.

4. Make full use of the advantages of rapid loading of Java 6 to detect and return class files existing in Java 6 in advance

To directly download and use Proguard, You need to configure the simple file proguard. pro. The configuration is as follows:

Parameters

-Include {filename}: Read the configuration parameters from the specified file.

-Basedirectory {directoryname}: Specify the base directory as the file name.

-Injars {class_path} specifies the application jar, war, ear, and directory to be processed.

-Outjars {class_path} specifies the name of the jar, war, ear, and directory to be output after processing.

-Libraryjars {classpath} specifies the application jar, war, ear, and library files required by the Directory to be processed.

-Dontskipnonpubliclibraryclasses specifies that non-public library classes are not ignored.

-Dontskipnonpubliclibraryclassmembers specifies that the visible Library Class Members of the package are not ignored.

Retain option

-Keep {Modifier} {class_specification} protects specified class files and Class Members

-Keepclassmembers {modifier} {class_specification} protects the members of the specified class. If this class is protected, it will be better protected.

-Keepclasseswithmembers {class_specification} protects the specified class and class members, but the condition is that all specified classes and Class Members must exist.

-Keepnames {class_specification} protects the names of members of the specified class and class if they are not compressed and deleted in the step)

-Keepclassmembernames {class_specification} protects the names of members of the specified class if they are not compressed and deleted in the step)

-Keepclasseswithmembernames {class_specification} protects the names of specified classes and Class Members. If all specified class members are present after the compression step)

-Printseeds {filename} lists the Member-keep options of classes and classes, and outputs them to the specified files.

Compression

-Dontshrink does not compress input class files

-Printusage {filename}

-Whyareyoukeeping {class_specification}

Optimization

-Dontoptimize: the input class file is not optimized.

-Assumenosideeffects {class_specification}: the specified method is assumed during optimization without any side effects.

-Allowaccessmodification: allows access to and modification of modifier classes and class members during optimization.

Obfuscation

-Dontobfuscate does not confuse input class files

-Printmapping {filename}

-Added obfuscation when applymapping {filename} is reused.

-Obfuscationdictionary {filename} uses the keyword in the given file as the name of the method to be confused

-Overloadaggressively: Application intrusive overload during Obfuscation

-Useuniqueclassmembernames: Determine the names of members of a unified obfuscation class to add obfuscation.

-Flattenpackagehierarchy {package_name} repacks all renamed packages and stores them in a given single package.

-Repackageclass {package_name} repacks all renamed class files and stores them in a given single package.

-Dontusemixedcaseclassnames does not produce a variety of class names when obfuscation is performed.

-Keepattributes {attribute_name,...} protects specified optional attributes, such as LineNumberTable, LocalVariableTable,

SourceFile, Deprecated, Synthetic, Signature, and InnerClasses.

-Renamesourcefileattribute {string} is used to set the given string constant in the source file.


/*************************************** ************/

Google added Proguard to android sdkafter android2.3 to make it easy. We only need to modify the code script file proguard-project.txt that has been installed by Google.

How can versions earlier than 2.3 be confused?

Copy the proguard-project.txt file from a project of Version 2.3 or later, put it in the root directory of the current project, modify the project. properties/default. in the properties file, add the following code at the end of the file: proguard.config1_proguard-project.txt. In this case, you can compile the project to perform global obfuscation. You only need to release the project. in properties # proguard. config =$ {sdk. dir}/tools/proguard/proguard-android.txt: proguard-project.txt on the line, but the code in the actual project is not obfuscated, such as adding a third-party library file, it cannot be obfuscated.

Although obfuscation has some advantages, it will also cause some troubles in the future. After obfuscation, debugging may be very troublesome, and we cannot understand abcd and other things. During the process of doing so, the transaction code part with the background is not retained, causing an error. It takes a long time to check.



650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/10324511H-0.jpg "style =" float: none; "title =" 1.jpg"/>

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/103245L13-1.jpg "style =" float: none; "title =" 2.jpg"/>

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/1032455236-2.jpg "style =" float: none; "title =" 3.jpg"/>




















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.