Official Implementation of Android code obfuscation

Source: Internet
Author: User

First, check the file "project. properties:












"Ant. properties" file, rewrite some values to adapt to your project structure. (Translation is very watery. Do not take it seriously)

This file is a code obfuscation configuration file written by Google in the tools/proguard folder of the SDK. It is a basic android code obfuscation configuration file.

Continue viewing the proguard-project.txt file:
















#-Keepclassmembers class fqcn. of. javascript. interface. for. webview {
# Public *;
#}

Translation completed...

Through the annotations of the two files, we can draw a conclusion:

With this sentence, code obfuscation is enabled.

Proguard-project.txt in.

If the third-party library is not introduced, the general proguard-android.txt rules are enough, but if there is a third-party library, in the case of confusion to ignore the third-party library, this requires adding rules to the proguard-project.txt file. (Android. support. ** has been processed in proguard-android.txt, So If android. support. v4 is used, you do not need to add code obfuscation rules ).

For the processing of the third sub-database, refer to: http://blog.csdn.net/u_xtian/article/details/7495023

Specifically, add in proguard-project.txt:

-Libraryjars **. jar (declare the lib file)

-Dontwarn com. xx. bbb. ** (no warning is prompted)
-Keep class com. xx. bbb. ** {*;} (do not confuse)

For example, Baidu map:

-Libraryjars libs/baidumapapi_v2_ipv3.jar

-Dontwarn com. baidu. mapapi .**
-Dontwarn com. baidu. platform .**
-Dontwarn com. baidu. location .**
-Dontwarn com. baidu. vi .**
-Dontwarn vi.com. gdi. bgl. android .**

-Keep class com. baidu. mapapi .**{*;}
-Keep class com. baidu. platform .**{*;}
-Keep class com. baidu. location .**{*;}
-Keep class com. baidu. vi .**{*;}
-Keep class vi.com. gdi. bgl. android .**{*;}

Some may be confused. I know how to avoid code obfuscation, but it is actually very easy to find these package names. Open Android Private Libraries.

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.