Android Proguard syntax, androidproguard

Source: Internet
Author: User

Android Proguard syntax, androidproguard

-Include {filename}: Read the configuration parameters from the specified file.
-Basedirectory {directoryname}: Specify the base directory as the file name.
-Injars {class_path} specifies the application jar, war, ear, and directory to be processed.
-Outjars {class_path} specifies the name of the jar, war, ear, and directory to be output after processing.
-Libraryjars {classpath} specifies the application jar, war, ear, and library files required by the Directory to be processed.
-Dontskipnonpubliclibraryclasses specifies that non-public library classes are not ignored.
-Dontskipnonpubliclibraryclassmembers specifies that the visible Library Class Members of the package are not ignored.

Retain option
-Keep {Modifier} {class_specification} protects specified class files and Class Members
-Keepclassmembers {modifier} {class_specification} protects the members of the specified class. If this class is protected, it will be better protected.
-Keepclasseswithmembers {class_specification} protects the specified class and class members, but the condition is that all specified classes and Class Members must exist.
-Keepnames {class_specification} protects the names of members of the specified class and class (if they are not compressed and deleted in the step)
-Keepclassmembernames {class_specification} protects the names of members of the specified class (if they are not removed from the compression step)
-Keepclasseswithmembernames {class_specification} protects the names of specified classes and Class Members. If all specified class members are present (after the compression step)
-Printseeds {filename} lists the Member-keep options of classes and classes, and outputs them to the specified files.

Compression
-Dontshrink does not compress input class files
-Printusage {filename}
-Whyareyoukeeping {class_specification}

Optimization
-Dontoptimize: the input class file is not optimized.
-Assumenosideeffects {class_specification}: the specified method is assumed during optimization without any side effects.
-Allowaccessmodification: allows access to and modification of modifier classes and class members during optimization.

Obfuscation
-Dontobfuscate does not confuse input class files
-Printmapping {filename}
-Added obfuscation when applymapping {filename} is reused.
-Obfuscationdictionary {filename} uses the keyword in the given file as the name of the method to be confused
-Overloadaggressively: Application intrusive overload during Obfuscation
-Useuniqueclassmembernames: Determine the names of members of a unified obfuscation class to add obfuscation.
-Flattenpackagehierarchy {package_name} repacks all renamed packages and stores them in a given single package.
-Repackageclass {package_name} repacks all renamed class files and stores them in a given single package.
-Dontusemixedcaseclassnames does not produce a variety of class names when obfuscation is performed.
-Keepattributes {attribute_name,...} protects the specified optional attributes, such as LineNumberTable, LocalVariableTable, SourceFile, Deprecated, Synthetic, Signature, and

InnerClasses.
-Renamesourcefileattribute {string}: Set the given string constant in the source file.

 

 

 

 

 

 

 

 

 

-Ignorewarnings # ignore warnings to avoid some warnings during packaging
-Optimizationpasses 5 # specify the code compression level
-Dontusemixedcaseclassnames # Use case-insensitive Mixture
-Dontskipnonpubliclibraryclasses # Whether to confuse third-party jar
-Dontpreverify # Whether to perform pre-check during Obfuscation
-Verbose # Whether to log during Obfuscation
-Optimizations! Code/simplification/arithmetic ,! Field /*,! Class/merging/* # obfuscation algorithm

-Libraryjars libs/treecore. jar

-Dontwarn android. support. v4. ** # by default, proguard checks whether each reference is correct. However, third-party libraries often have classes that are not used and are not correctly referenced. If not configured, the system reports an error.
-Dontwarn android. OS .**
-Keep class android. support. v4. ** {*;} # keep classes that are not obfuscated
-Keep class com. baidu .**{*;}
-Keep class vi.com. gdi. bgl. android .**{*;}
-Keep class android. OS .**{*;}

-Keep interface android. support. v4.app .**{*;}
-Keep public class * extends android. support. v4 .**
-Keep public class * extends android. app. Fragment

-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. support. v4.widget
-Keep public class * extends com. sqlcrypt. database
-Keep public class * extends com. sqlcrypt. database. sqlite
-Keep public class * extends com. treecore .**
-Keep public class * extends de. greenrobot. dao .**


-Keepclasseswithmembernames class * {# Keep the native method not obfuscated
Native <methods>;
}

-Keepclasseswithmembers class * {# Keep the custom control class unchanged
Public <init> (android. content. Context, android. util. AttributeSet );
}

-Keepclasseswithmembers class * {# Keep the custom control class unchanged
Public <init> (android. content. Context, android. util. AttributeSet, int );
}

-Keepclassmembers class * extends android. app. Activity {// persistence class member
Public void * (android. view. View );
}

-Keepclassmembers enum * {# Keep The enum class of the enumeration unobfuscated
Public static ** [] values ();
Public static ** valueOf (java. lang. String );
}

-Keep class * implements android. OS. Parcelable {# keep Parcelable unchanged
Public static final android. OS. Parcelable $ Creator *;
}

-Keep class MyClass; # keep the classes defined by you from being confused </init> </methods>

 

 

 

 

 

 

 

 

 

 

 

#-------------------------------------
# Original android obfuscation Template
#-------------------------------------

#----------------------------------
# Execution can be performed through a specified number of Optimizations
#-Optimizationpasses n
#----------------------------------
-Optimizationpasses 5

#----------------------------------
# Classes with different names are not generated during obfuscation.
#-Dontusemixedcaseclassnames
#----------------------------------
#-Dontusemixedcaseclassnames
#----------------------------------
# Specify not to ignore non-public library classes
#-Dontskipnonpubliclibraryclasses
#----------------------------------
#-Dontskipnonpubliclibraryclasses

#----------------------------------
# No pre-check
#-Dontpreverify
#----------------------------------
#-Dontpreverify

#----------------------------------
# Output generation information
#-Verbose
#----------------------------------
-Verbose

#----------------------------------
# Optimization Options
# Optimizations {optimization_filter}
#----------------------------------
-Optimizations! Code/simplification/arithmetic ,! Field /*,! Class/merging /*

-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>;
}
#-----------------
# Modify and merge
#-----------------
-Keep public class * extends android. view. View {
Public <init> (android. content. Context );
Public <init> (android. content. Context, android. util. AttributeSet );
Public <init> (android. content. Context, android. util. AttributeSet, int );
Public void set *(...);
}

-Keepclassmembers enum *{
Public static ** [] values ();
Public static ** valueOf (java. lang. String );
}

-Keep class * implements android. OS. Parcelable {
Public static final android. OS. Parcelable $ Creator *;
}

#--------------------------
# Protection Type-Description of keepattributes
# Exceptions, Signature, Deprecated, SourceFile, SourceDir, LineNumberTable, LocalVariableTable,
# LocalVariableTypeTable, Synthetic, EnclosingMethod, RuntimeVisibleAnnotations, RuntimeInvisibleAnnotations,
# RuntimeVisibleParameterAnnotations, RuntimeInvisibleParameterAnnotations, and AnnotationDefault
#--------------------
-Keepattributes **
-Libraryjars <java. home>/lib/rt. jar

#----------------------
# Do not compress the specified file
#-Dontshrink
#----------------------
-Dontshrink

#----------------------
# Do not optimize the specified file
#-Dontoptimize
#-----------------------
-Dontoptimize

#-----------------------
# Do not confuse the specified file
#-Dontobfuscate
#-----------------------

# ----- Confusion package path -------
-Repackageclasses''
-Flattenpackagehierarchy''
-Target 1.6

# -------- The following is the use of roboguice-1.1.2.jar and guice-2.0-no_app.jar functions need to protect the field and class related --------
-Keep class com. google. inject. Binder
-Keepclassmembers class *{
@ Com. google. inject. Inject <init> (...);
}
-Keepclassmembers class *{
Void * (** On * Event );
}
-Keepclassmembers class **. R$ *{
Public static <fields>;
}

# ------ Jar package used during compilation
-Libraryjars D:/dev_rc/android-sdk-windows/add-ons/addon_google_apis_google_inc_11/libs/maps. jar

# ------ Protect Google third-party jar packages and interface special effects ----------
-Keep class android. support. v4 .**
-Dontwarn android. support. v4 .**

# ------ Protect Baidu address jar package --------
-Keep class com. baidu. mapapi .**{*;}
-Dontwarn com. baidu. mapapi .**

# --- Ignore the warning of the following classes during packaging --
-Dontwarn com. classpackage. AA

#-Keepnames class * implements java. io. Serializable
# --------- Protect the field names in all entities ----------
-Keepclassmembers class * implements java. io. Serializable {
<Fields>;
}

# --------- Name of all methods in the protection class ------------
-Keepclassmembers class *{
Public <methods>;
}

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.