Android project source code obfuscation Solution

Source: Internet
Author: User

Android project source code obfuscation Solution
Considering the code security, it is easy for others to steal their work. Today, I am eager to learn about Android code obfuscation. I want to help my friends who are learning android to avoid detours in the future.
Because my android project version is 1.6, Google added support for code obfuscation to 2.2 and later versions. However, code obfuscation can be performed in earlier versions, but you only need to manually configure it.
It is also quite simple. However, I encountered many problems during the configuration process. I found a lot of information online and did not solve my problem. Through constant exploration, we found a solution from a foreign website.
The solution is also very simple. The following is my solution.
1. Add proguard. Config = proguard. cfg directly to the default. properties File above sdk2.2.
2. In addition to the above settings, sdk2.2 also requires the following Configuration:
Copy the proguard. cfg file from other sdk2.2 and above to the project;
If there is no external jar package reference in the project, you only need to add a line-dontwarn to remove the warning;
If there is an external jar package reference, add two lines
-Dontwarn
-Dontskipnonpubliclibraryclassmembers
3. If an error persists, A. Check the SDK path with spaces. B. Change-dontpreverify to-dontoptimize.

 

 

------------------------------------------------------------- The following is the content of the proguard. cfg file -----------------------
-Optimizationpasses 5
-Dontusemixedcaseclassnames
-Dontskipnonpubliclibraryclasses
-Dontpreverify
-Verbose
-Optimizations! Code/simplification/arithmetic ,! Field /*,! Class/merging /*

-Dontwarn
-Dontskipnonpubliclibraryclassmembers

-Keep public class * extends Android. App. Activity
-Keep public class * extends Android. App. Application
-Keep public class * extends Android. App. Service
-Keep public class * extends Android. content. broadcastreceiver
-Keep public class * extends Android. content. contentprovider
-Keep public class * extends Android. App. Backup. backupagenthelper
-Keep public class * extends Android. Preference. Preference
-Keep public class com. Android. Vending. Licensing. ilicensingservice

-Keepclasseswithmembernames class *{
Native <Methods>;
}

-Keepclasseswithmembers class *{
Public <init> (Android. content. Context, Android. util. attributeset );
}

-Keepclasseswithmembers class *{
Public <init> (Android. content. Context, Android. util. attributeset, INT );
}

-Keepclassmembers class * extends Android. App. Activity {
Public void * (Android. View. View );
}

-Keepclassmembers Enum *{
Public static ** [] values ();
Public static ** valueof (Java. Lang. String );
}

-Keep class * implements Android. OS. parcelable {
Public static final Android. OS. parcelable $ creator *;
}

Note: QQ technology exchange group: add one if you are interested in 108614806.

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.