diff --git a/README.md b/README.md index 8f96a97..aea640d 100644 --- a/README.md +++ b/README.md @@ -10,14 +10,19 @@ Request additional libraries through issues. Pull requests are welcome. [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-android--proguard--snippets-brightgreen.svg?style=flat)](https://android-arsenal.com/details/3/1242) ### Usage + +#### 1. Include the proguard files in your project +First of all, add the repository as a git submodule (or just copy the proguard files in your project). + +#### 2. Integrate the proguard files in your project ```groovy android { buildTypes { release { minifyEnabled true // Library specific proguard files - proguardFile 'proguard-google-play-services.pro' - proguardFile 'proguard-gson.pro' + proguardFile '$PATH_TO_THE_PROGUARD_FILES/proguard-google-play-services.pro' + proguardFile '$PATH_TO_THE_PROGUARD_FILES/proguard-gson.pro' ... // Default proguard files & project app specific rules, // see examples folder for more information @@ -32,8 +37,7 @@ android { Instead of declaring each configuration file manually, you could also store them in a seperate directory and include them all at once: ```groovy -FileCollection proGuardFileCollection = files { file('./proguard').listFiles() } -proguardFiles(proGuardFileCollection) +proguardFiles fileTree(dir: "$PATH_TO_THE_PROGUARD_FILES", include: ["*.pro"]).asList().toArray() ``` ### Libraries diff --git a/libraries/proguard-butterknife-8.pro b/libraries/proguard-butterknife-8.pro new file mode 100644 index 0000000..e3f1d95 --- /dev/null +++ b/libraries/proguard-butterknife-8.pro @@ -0,0 +1,10 @@ +#ButterKnife 8 + +# Retain generated class which implement Unbinder. +-keep public class * implements butterknife.Unbinder { public (...); } + +# Prevent obfuscation of types which use ButterKnife annotations since the simple name +# is used to reflectively look up the generated ViewBinding. +-keep class butterknife.* +-keepclasseswithmembernames class * { @butterknife.* ; } +-keepclasseswithmembernames class * { @butterknife.* ; } \ No newline at end of file diff --git a/libraries/proguard-dart.pro b/libraries/proguard-dart.pro new file mode 100644 index 0000000..3b5b7c5 --- /dev/null +++ b/libraries/proguard-dart.pro @@ -0,0 +1,13 @@ +## Dart 2.x +# https://github.com/f2prateek/dart#proguard + +-dontwarn com.f2prateek.dart.internal.** +-keep class **$$ExtraInjector { *; } +-keepclasseswithmembernames class * { + @com.f2prateek.dart.* ; +} + +#for dart 2.0 only +-keep class **Henson { *; } +-keep class **$$IntentBuilder { *; } + diff --git a/libraries/proguard-dbflow-4.0.5.pro b/libraries/proguard-dbflow-4.0.5.pro new file mode 100644 index 0000000..56beb6b --- /dev/null +++ b/libraries/proguard-dbflow-4.0.5.pro @@ -0,0 +1,8 @@ +# Proguard Configuration for Dbflow 4.0.5 + +-keepattributes Annotation + +-keep class * extends com.raizlabs.android.dbflow.config.DatabaseHolder { *; } + +-keep class net.sqlcipher.** { *; } +-dontwarn net.sqlcipher. diff --git a/libraries/proguard-gson.pro b/libraries/proguard-gson.pro index 2248c58..694025f 100644 --- a/libraries/proguard-gson.pro +++ b/libraries/proguard-gson.pro @@ -1,5 +1,4 @@ -## GSON 2.2.4 specific rules ## - +##---------------Begin: proguard configuration for Gson ---------- # 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 @@ -7,8 +6,17 @@ # For using GSON @Expose annotation -keepattributes *Annotation* --keepattributes EnclosingMethod - # Gson specific classes -keep class sun.misc.Unsafe { *; } --keep class com.google.gson.stream.** { *; } +#-keep class com.google.gson.stream.** { *; } + +# Application classes that will be serialized/deserialized over Gson +-keep class com.google.gson.examples.android.model.** { *; } + +# Prevent proguard from stripping interface information from TypeAdapterFactory, +# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter) +-keep class * implements com.google.gson.TypeAdapterFactory +-keep class * implements com.google.gson.JsonSerializer +-keep class * implements com.google.gson.JsonDeserializer + +##---------------End: proguard configuration for Gson ---------- \ No newline at end of file diff --git a/libraries/proguard-itext.pro b/libraries/proguard-itext.pro new file mode 100644 index 0000000..b82bd4e --- /dev/null +++ b/libraries/proguard-itext.pro @@ -0,0 +1,25 @@ +# Proguard Configuration for iText 5.5.11 + +-keep class org.spongycastle.** { *; } +-dontwarn org.spongycastle.** + +-keep class com.itextpdf.** { *; } + +-keep class javax.xml.crypto.dsig.** { *; } +-dontwarn javax.xml.crypto.dsig.** + +-keep class org.apache.jcp.xml.dsig.internal.dom.** { *; } +-dontwarn org.apache.jcp.xml.dsig.internal.dom.** + +-keep class javax.xml.crypto.dom.** { *; } +-dontwarn javax.xml.crypto.dom.** + +-keep class org.apache.xml.security.utils.** { *; } +-dontwarn org.apache.xml.security.utils.** + +-keep class javax.xml.crypto.XMLStructure +-dontwarn javax.xml.crypto.XMLStructure + +-keep interface com.itextpdf.** + +-dontwarn com.itextpdf.** diff --git a/libraries/proguard-opencsv.pro b/libraries/proguard-opencsv.pro new file mode 100644 index 0000000..570a51b --- /dev/null +++ b/libraries/proguard-opencsv.pro @@ -0,0 +1,3 @@ +# Proguard configuration for openCSV + +-dontwarn org.apache.commons.beanutils.** diff --git a/libraries/proguard-parceler.pro b/libraries/proguard-parceler.pro index 80fccd6..233ccfb 100644 --- a/libraries/proguard-parceler.pro +++ b/libraries/proguard-parceler.pro @@ -1,8 +1,13 @@ # Parceler rules # Source: https://github.com/johncarl81/parceler#configuring-proguard --keep class * implements android.os.Parcelable { - public static final android.os.Parcelable$Creator *; -} - +-keep interface org.parceler.Parcel +-keep @org.parceler.Parcel class * { *; } +-keep class **$$Parcelable { *; } -keep class org.parceler.Parceler$$Parcels + +-dontwarn org.parceler.apache.commons.** +-dontwarn org.parceler.ParcelAnnotationProcessor +-dontwarn org.parceler.transfuse.bootstrap.BootstrapProcessor +-dontwarn org.parceler.codemodel.util.SingleByteEncoder +-dontwarn java.beans.** diff --git a/libraries/proguard-rx-java.pro b/libraries/proguard-rx-java.pro index 73bfaba..4ead3ca 100644 --- a/libraries/proguard-rx-java.pro +++ b/libraries/proguard-rx-java.pro @@ -1,5 +1,13 @@ -# RxJava 0.21 - +# RxJava 1.2.4 + +-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* { + long producerIndex; + long consumerIndex; +} +-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef { + long producerNode; + long consumerNode; +} -keep class rx.schedulers.Schedulers { public static ; } diff --git a/libraries/proguard-square-okhttp3.pro b/libraries/proguard-square-okhttp3.pro index 64e6852..112b4aa 100644 --- a/libraries/proguard-square-okhttp3.pro +++ b/libraries/proguard-square-okhttp3.pro @@ -1,6 +1,3 @@ # OkHttp --keepattributes Signature --keepattributes *Annotation* --keep class okhttp3.** { *; } --keep interface okhttp3.** { *; } --dontwarn okhttp3.** \ No newline at end of file +-dontwarn okhttp3.** +-dontwarn javax.annotation.* \ No newline at end of file diff --git a/libraries/proguard-square-okio.pro b/libraries/proguard-square-okio.pro index 589e679..bf45861 100644 --- a/libraries/proguard-square-okio.pro +++ b/libraries/proguard-square-okio.pro @@ -1,5 +1,2 @@ # Okio --keep class sun.misc.Unsafe { *; } --dontwarn java.nio.file.* --dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement --dontwarn okio.** \ No newline at end of file +-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement \ No newline at end of file diff --git a/libraries/proguard-square-retrofit2.pro b/libraries/proguard-square-retrofit2.pro index 586c0f8..57ea6f5 100644 --- a/libraries/proguard-square-retrofit2.pro +++ b/libraries/proguard-square-retrofit2.pro @@ -1,11 +1,9 @@ # Retrofit 2.X ## https://square.github.io/retrofit/ ## --dontwarn retrofit2.** --keep class retrofit2.** { *; } --keepattributes Signature --keepattributes Exceptions - --keepclasseswithmembers class * { - @retrofit2.http.* ; -} +# Platform calls Class.forName on types which do not exist on Android to determine platform. +-dontnote retrofit2.Platform +# Platform used when running on Java 8 VMs. Will not be used at runtime. +-dontwarn retrofit2.Platform$Java8 +# Retain generic signatures used for parsing the return types reflectively. +-keepattributes Signature \ No newline at end of file diff --git a/libraries/proguard-viewpagerindicator.pro b/libraries/proguard-viewpagerindicator.pro new file mode 100644 index 0000000..4ef9de3 --- /dev/null +++ b/libraries/proguard-viewpagerindicator.pro @@ -0,0 +1,4 @@ +#View Pager Indicator +# https://github.com/JakeWharton/ViewPagerIndicator/issues/366#issuecomment-159972837 + +-dontwarn com.viewpagerindicator.LinePageIndicator \ No newline at end of file