Android Developers: ProGuard, androidproguard

Source: Internet
Author: User

Android Developers: ProGuard, androidproguard

By deleting unused code, the ProGuard tool uses a semantic fuzzy name to rename classes, fields, and methods to reduce, optimize, and confuse your code. The result is a smaller. APK file that is more difficult to reverse to the project. Because ProGuard makes your application more difficult to reverse engineer, it is especially important to use it when your published application uses security-sensitive features.

 

ProGuard has been integrated into the Android build system, so you do not need to call it manually. ProGuard only runs when you build your application in release mode, so you do not need to process obfuscated code in Debug mode. Running ProGuard is completely optional, but it is strongly recommended.

 

This document describes how to start and configure ProGuard and decode obfuscated stack traces using the retrace tool.

 

Start ProGuard

------------------------------------------------------------

When you create an Android project, a proguard. cfg file is automatically generated under the root directory of the project. This file defines how ProGuard can optimize and confuse your code, so it is very important that you know how to customize it according to your needs. The default configuration file only covers general situations, so you may have to edit it for your own needs. Read the following chapter about customizing ProGuard configuration files.

 

To start ProGuard to make it part of Ant or Eclipse build, set the proguard. config attribute in the <project_root>/project. properties file. This path can be an absolute path or a path relative to the project root directory.

 

Note: When using Android Studio, you must add the build type to your gradle. build File. For more information, see Gradle Plug User Guid.

 

If you place the proguard. cfg file in its default location (project and directory), you can specify its location as follows:

Proguard. config = proguard. cfg

 

You can also move the file to any location you want and specify its absolute path:

Proguard. config =/path/to/proguard. cfg

 

When you build your application in Release mode, the system automatically checks whether the proguard. config attribute is set by running ant Release or using the Export Wizard of Eclipse. If the token is set, proguardautomatically processes the application bytecode before packaging all the data to the. APK file. In Debug mode, do not call ProGuard to make debugging more difficult.

 

Output the following file after running ProGuard:

 

Dump.txt

Describes the internal structure of all class files in the apk File

Mapping.txt
Lists mappings between original and obfuscated classes, methods, and member names. This file is very important when you receive a Bug report from the release build, because it escapes the obfuscation stack back to the original class, method, and member name. For more information, see Decoding Obfuscated Stack Traces.

Seeds.txt
Lists the classes and members that are not obfuscated.

Usage.txt
The code deleted from .apk is listed.

These files are placed in the following directory:

  • <Project_root>/bin/proguard if you use Ant.

  • <Project_root>/proguard if you use Eclipse.

Note: every time you run a build in release mode, these files are overwritten by the latest file generated by ProGuard. Each time you release your applications, save their copies to build a Bug report for anti-obfuscation from your release.

Related Article

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.