Skip to content

Instantly share code, notes, and snippets.

@jonikarppinen
Last active August 1, 2017 09:56
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jonikarppinen/07de110fd0d9ed90b202 to your computer and use it in GitHub Desktop.
Save jonikarppinen/07de110fd0d9ed90b202 to your computer and use it in GitHub Desktop.
Example ProGuard config for a project using RxJava, Guava and Gson
# 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 property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Use unique member names to make stack trace reading easier
-useuniqueclassmembernames
# Some libs use annotations like javax.annotation.Nullable which are not available in Android runtime.
# However, that does not matter, so just mute warnings:
# For Guava:
-dontwarn javax.annotation.**
-dontwarn javax.inject.**
-dontwarn sun.misc.Unsafe
# For RxJava:
-dontwarn org.mockito.**
-dontwarn org.junit.**
-dontwarn org.robolectric.**
##---------------Begin: proguard configuration for Gson ----------
# Adapted from https://code.google.com/p/google-gson/source/browse/trunk/examples/android-proguard-example/proguard.cfg
#
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature
# We use Gson's @SerializedName annotation which won't work without this:
-keepattributes *Annotation*
# Gson specific classes
#-keep class sun.misc.Unsafe { *; }
#-keep class com.google.gson.stream.** { *; }
# Classes that will be serialized/deserialized over Gson
# http://stackoverflow.com/a/7112371/56285
-keep class fi.company.project.models.json.** { *; }
##---------------End: proguard configuration for Gson ----------
# Remove logging calls
-assumenosideeffects class android.util.Log {
public static boolean isLoggable(java.lang.String, int);
public static int v(...);
public static int i(...);
public static int w(...);
public static int d(...);
public static int e(...);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment