Android Code Obfuscation Proguard.flags

Source: Internet
Author: User

When we compile the user version of the Android system, sometimes there will be proguard errors, in resolving this error, we need to know some knowledge:

What is 1,proguard used for?

Simply put, he is a tool used to confuse Java code.

2, where is this thing implemented?

We generally support it in the Android.mk file, such as:

1) Specify the Proguard.flags file for native methods and variables that do not need to be confused local_proguard_flag_files: = Proguard.flags

2) Set the use and non-use:

(1), compile the project, do not need to use code obfuscation tool for code obfuscation: local_proguard_enable: = disable

(2), if not set, we use local_proguard_enable by default: = Full means to confuse the project code

3, how to solve?

For example, we use JNI in the Android project, when using the Proguard, we will find that the native method has many variables can not be found, after careful analysis you will find that the reason is Progurad optimized off,

Therefore, we suggest that Progurad should be used with caution in JNI applications. Since found, but we want to use Progurad ah, how to do?

1) Add the following code to the ANDROID.MK:

Local_proguard_flag_files: = Proguard.flags

2) Add classes and methods in the Proguard.flags file that do not require proguard optimizations, such as browser:

-keep class com.android.browser.preferences.*

After this treatment, basically the problem is solved!

Android Code Obfuscation Proguard.flags

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.