Java Proguard Code Obfuscation __java

Source: Internet
Author: User

Java-written code is very easy to decompile, but you can use Proguard to do your best to protect our code, Proguard specific use can refer to the official documentation (http://proguard.sourceforge.net/), Write down my configuration now (in actual use) for reference


1. Download Proguard to http://proguard.sourceforge.net/
2. Ready to have the jar bag, I'm here for example is Yulore_yellowsdk.jar
3. Unpack the Proguard, double-click the Proguardgui.bat in the Bin directory to open the Proguard graphical window, as shown in the following figure:



Proguard Graphical window:



Select the obfuscation profile proguard_common.cfg as follows:



When you are done, click Next and select the jar file you want to confuse, as follows:



Click the ADD input button and select the jar file to be confused as follows:



Similarly, click Add Output selection to confuse the build Jar file save path as follows:



When you are done, click Next to enter the following interface:



Basically do not need to modify, directly click the Next button, into the next interface



Do not change, just click Next



You don't have to make any changes, just click Next



Don't make any changes, just click Next



Come to this interface, click on the process Start code obfuscation, as follows:




Confused after the completion of the interface, as follows:




confusing configuration file proguard_common.cfg


# to enable Proguard in your project, edit Project.Properties # to define the Proguard.config property as described in tha
T file.
# ADD Project specific Proguard rules here.  # By default, the flags in this file are appended to flags specified # in ${sdk.dir}/tools/proguard/proguard-android.txt #
You can edit the ' include path ' and order by changing the ' Proguard # include in Project.Properties. # for more details, and # http://developer.android.com/guide/developing/tools/proguard.html # ADD any project Specifi C Keep Options here: # If your project uses WebView with JS, uncomment the following # and specify the fully qualified CL Ass name to the JavaScript interface # class: #-keepclassmembers class Fqcn.of.javascript.interface.for.webview {# publ
IC *; #}-dontshrink-optimizationpasses 5-dontusemixedcaseclassnames-dontskipnonpubliclibraryclasses-dontpreverify- Verbose-optimizations!code/simplification/arithmetic,!field/*,!class/merging/*-libraryjars D:/proguard_Test/proguard_libs/map.jar-libraryjars D:/proguard_test/proguard_libs/core.jar-libraryjars D:/proguard_Test/ Proguard_libs/geocoder_location.jar-libraryjars D:/proguard_test/proguard_libs/android.jar-libraryjars D:/ Proguard_test/proguard_libs/annotations.jar-libraryjars D:/proguard_test/proguard_libs/android-support-v4.jar- Libraryjars D:/proguard_test/proguard_libs/fastjson.jar-keep public class * extends Android.app.activity-keep public c Lass * extends Android.app.application-keep public class * extends Android.app.service-keep public class * extends Andro Id.content.broadcastreceiver-keep public class * extends Android.content.contentprovider-keep public class * extends and Roid.app.backup.backupagenthelper-keep public class * extends Android.preference.preference-keep public class Com.android.vending.licensing.ilicensingservice-keep public class * extends Android.view.view-keep public class * Exte NDS Android.app.application-keep class com.yulore.yellowsdk.view.** { *; -keep class com.yulore.yellowsdk.cache.** {*;}-keep class com.yulore.yellowsdk.entity.** {*;}-keep class Com.yulor e.yellowsdk.http.** {*;}-keep class Com.yulore.yellowsdk.util.apikeyfactory-keepclasseswithmembers class * {Nati
ve <methods>;

}-keepclasseswithmembers class * {public static <methods>;}

-keepclasseswithmembers class * {public <init> (Android.content.Context, android.util.AttributeSet);}

-keepclasseswithmembers class * {public <init> (Android.content.Context, android.util.AttributeSet, int);}
    -keepclassmembers enum * {public static **[] values ();
public static * * VALUEOF (java.lang.String);

}-keep class * Implements android.os.Parcelable {public static final Android.os.parcelable$creator *;} -dontwarn com.mapabc.mapapi.route.**-keep class com.mapabc.mapapi.map.** {*;}-keep class com.mapabc.mapapi.route.**

{ *; } -dontwarn android.support.v4.**-keep class android.support.v4.** {*;}  
-keep class android.support.v4.app.** {*;}  
-keep class android.support.v4.view.** {*;} -keep public class * extends android.support.v4.**-keepclassmembers class * {public <init> (org.json.JSONObject
);
 }-keep class com.alibaba.fastjson.** {*;}



proguard root directory:



Dependent jar Package directory:





Any problems with the obfuscation process can be referred to the following Web sites:

Http://docs.huihoo.com/proguard/manual/troubleshooting.html






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.