Skip to content

Instantly share code, notes, and snippets.

@anilbattini
Last active October 16, 2018 02:52
Show Gist options
  • Save anilbattini/1e6582bdd98e3d9e47e892dbbc2e3581 to your computer and use it in GitHub Desktop.
Save anilbattini/1e6582bdd98e3d9e47e892dbbc2e3581 to your computer and use it in GitHub Desktop.
Proguard generic file
### For much better take on proguard, read the following medium post, its just 5 min read.
# https://medium.com/@neeluiscoming/how-simple-setting-up-proguard-is-and-how-we-make-it-hard-35edb33653a4
###
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-optimizationpasses 5
#When not preverifing in a case-insensitive filing system, such as Windows. Because this tool unpacks your processed jars, you should then use:
-dontusemixedcaseclassnames
#Specifies not to ignore non-public library classes. As of version 4.5, this is the default setting
-dontskipnonpubliclibraryclasses
#Preverification is irrelevant for the dex compiler and the Dalvik VM, so we can switch it off with the -dontpreverify option.
-dontpreverify
#Specifies to write out some more information during processing. If the program terminates with an exception, this option will print out the entire stack trace, instead of just the exception message.
-verbose
#The -optimizations option disables some arithmetic simplifications that Dalvik 1.0 and 1.5 can’t handle. Note that the Dalvik VM also can’t handle aggressive overloading (of static fields).
#To understand or change this check http://proguard.sourceforge.net/index.html#/manual/optimizations.html
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
##-libraryjars ./libs/
##-libraryjars libs/
-assumenosideeffects class android.util.Log {
public static *** d(…);
public static *** w(…);
public static *** e(…);
public static *** i(…);
public static *** v(…);
}
## For using GSON @Expose annotation
-keepattributes *Annotation*
-dontwarn javax.annotation.**
## Gson specific classes
-keep class sun.misc.Unsafe { *; }
-dontwarn sun.misc.**
##########
# Parcelables: Mantain the parcelables working
##########
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keepclassmembers class * implements android.os.Parcelable {
static ** CREATOR;
}
## Third party lib
-keep class com.bumptech.** { *; }
-dontwarn com.bumptech.**
-keep class okio.** { *; }
-dontwarn okio.**
-keep class retrofit2.** { *; }
-dontwarn retrofit2.**
-keep class org.webrtc.** { *; }
-dontwarn org.webrtc.**
-keep class okhttp3.** { *; }
-dontwarn okhttp3.**
-keep class me.dm7.barcodescanner.** { *; }
####################
# android specific #
####################
-dontwarn android.content.**
-keep class android.support.design.widget.** { *; }
## support @Keep annotation. With this,
## you can simply add ‘@Keep’ to any class/method/field to be kept from obfuscation
-keep class android.support.annotation.Keep
-keep @android.support.annotation.Keep class * {*;}
-keepclasseswithmembers class * {
@android.support.annotation.Keep <methods>;
}
-keepclasseswithmembers class * {
@android.support.annotation.Keep <fields>;
}
-keepclasseswithmembers class * {
@android.support.annotation.Keep <init>(…);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class **.R$* {
public static <fields>;
}
# do not strip enums including our custom implementations
-keepclassmembers enum * { *; }
## google stuff
-keep public class com.google.android.gms.* { public *; }
-dontwarn com.google.android.gms.**
# Data Binding
-dontwarn android.databinding.**
-keep class android.databinding.** { *; }
# Kotlin specific stuff
-keep class org.jetbrains.** { *; }
-keep class kotlin.** { *; }
#-keep class kotlin.Metadata { *; }
-dontwarn kotlin.**
-keepclassmembers class **$WhenMappings {
<fields>;
}
-keepclassmembers class kotlin.Metadata {
public <methods>;
}
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
static void checkParameterIsNotNull(java.lang.Object, java.lang.String);
}
# Keep native methods
-keepclasseswithmembers class * {
native <methods>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment