Skip to content

Instantly share code, notes, and snippets.

@miao1007
Created May 18, 2015 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miao1007/e07d9b8589c060d312fc to your computer and use it in GitHub Desktop.
Save miao1007/e07d9b8589c060d312fc to your computer and use it in GitHub Desktop.
Square proguard
buildTypes {
release {
minifyEnabled true //run proguard
shrinkResources true
proguardFile 'proguard-square.pro'
// Default proguard files(including support libs)
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}
#ButterKnife
#Butter Knife generates and uses classes dynamically which means that static analysis tools like ProGuard may think they are unused. In order to prevent them from being removed, explicitly mark them to be kept. To prevent ProGuard renaming classes that use @InjectView on a member field the keepclasseswithmembernames option is used.
-keep class butterknife.** { *; }
-dontwarn butterknife.internal.**
-keep class **$$ViewInjector { *; }
-keepclasseswithmembernames class * {
@butterknife.* <fields>;
}
-keepclasseswithmembernames class * {
@butterknife.* <methods>;
}
#Otto
#This ensures your annotated methods aren't removed by ProGuard.
#http://square.github.io/otto/
-keepattributes *Annotation*
-keepclassmembers class ** {
@com.squareup.otto.Subscribe public *;
@com.squareup.otto.Produce public *;
}
# retrofit
#If you are using Proguard in your project add the following lines to your configuration:
-dontwarn retrofit.**
-keep class retrofit.** { *; }
-keepattributes Signature
-keepattributes Exceptions
# OkHttp/Picasso
-keepattributes Signature
-keepattributes *Annotation*
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-dontwarn com.squareup.okhttp.**
# Okio
-keep class sun.misc.Unsafe { *; }
-dontwarn java.nio.file.*
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-dontwarn okio.**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment