Enabled proguard to reduce APK size and added the pertinent proguard rules to avoid removing too much code.

master
Severiano Jaramillo 2019-04-26 16:23:04 -05:00
parent 1eb9b64b45
commit ac7e729816
2 changed files with 94 additions and 34 deletions

View File

@ -28,14 +28,13 @@ android {
}
buildTypes {
release {
minifyEnabled false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// enable crashlytics
ext.enableCrashlytics = true
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
resValue("string", "PORT_NUMBER", "8082")
// disable crashlytics
ext.enableCrashlytics = false

123
app/proguard-rules.pro vendored
View File

@ -20,37 +20,76 @@
# hide the original source file name.
#-renamesourcefileattribute SourceFile
###### itextpdf & opencsv
-dontwarn java.awt.**
-dontwarn javax.security.**
-dontskipnonpubliclibraryclasses
# TODO enable optimization
-dontoptimize
-dontpreverify
# TODO enable obfuscation
-dontobfuscate
-verbose
##--------------- proguard configuration for ITextPDF ----------
-dontwarn com.itextpdf.**
##--------------- proguard configuration for openCSV ----------
-dontwarn java.beans.**
-dontwarn com.itextpdf.awt.**
-dontwarn javax.imageio.**
-keep class org.bouncycastle.**
-dontwarn org.bouncycastle.**
##--------------- 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
-keep class org.spongycastle.** { *; }
-dontwarn org.spongycastle.**
# For using GSON @Expose annotation
-keepattributes *Annotation*
-keep class javax.xml.crypto.dsig.** { *; }
-dontwarn javax.xml.crypto.dsig.**
# Gson specific classes
-dontwarn sun.misc.**
#-keep class com.google.gson.stream.** { *; }
-keep class org.apache.jcp.xml.dsig.internal.dom.** { *; }
-dontwarn org.apache.jcp.xml.dsig.internal.dom.**
# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { *; }
-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
# 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
###### OkHttp
##--------------- proguard configuration for Retrofit ----------
# Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and
# EnclosingMethod is required to use InnerClasses.
-keepattributes Signature, InnerClasses, EnclosingMethod
# Retrofit does reflection on method and parameter annotations.
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations
# Retain service method parameters when optimizing.
-keepclassmembers,allowshrinking,allowobfuscation interface * {
@retrofit2.http.* <methods>;
}
# Ignore annotation used for build tooling.
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
# Ignore JSR 305 annotations for embedding nullability information.
-dontwarn javax.annotation.**
# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath.
-dontwarn kotlin.Unit
# Top-level functions that can only be used by Kotlin.
-dontwarn retrofit2.KotlinExtensions
# With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy
# and replaces all potential values with null. Explicitly keeping the interfaces prevents this.
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface <1>
##--------------- proguard configuration for OkHttp ----------
# JSR 305 annotations are for embedding nullability information.
-dontwarn javax.annotation.**
@ -64,16 +103,38 @@
-dontwarn okhttp3.internal.platform.ConscryptPlatform
###### bitcoinj
-dontwarn org.bitcoinj.store**
##--------------- proguard configuration for Okio ----------
# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
-dontwarn org.codehaus.mojo.animal_sniffer.*
###### ???
-keep class org.slf4j.** { *; }
-dontwarn org.slf4j.**
##--------------- proguard configuration for bitcoinj ----------
# source: https://github.com/bitcoin-wallet/bitcoin-wallet/blob/v7.07/wallet/proguard.cfg#L49
-keep,includedescriptorclasses class org.bitcoinj.wallet.Protos$** { *; }
-keepclassmembers class org.bitcoinj.wallet.Protos { com.google.protobuf.Descriptors$FileDescriptor descriptor; }
-keep,includedescriptorclasses class org.bitcoin.protocols.payments.Protos$** { *; }
-keepclassmembers class org.bitcoin.protocols.payments.Protos { com.google.protobuf.Descriptors$FileDescriptor descriptor; }
-dontwarn org.bitcoinj.store.WindowsMMapHack
-dontwarn org.bitcoinj.store.LevelDBBlockStore
-dontnote org.bitcoinj.crypto.DRMWorkaround
-dontnote org.bitcoinj.crypto.TrustStoreLoader$DefaultTrustStoreLoader
-dontnote com.subgraph.orchid.crypto.PRNGFixes
-dontwarn okio.DeflaterSink
-dontwarn okio.Okio
-dontnote com.squareup.okhttp.internal.Platform
-dontwarn org.bitcoinj.store.LevelDBFullPrunedBlockStore**
-dontwarn org.bitcoinj.protocols.channels.PaymentChannelClient
###### Firabase Crashlytics
-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception
##--------------- proguard configuration for Crashlytics ----------
# source https://stackoverflow.com/a/34751033/5428997
-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**
-keepattributes SourceFile,LineNumberTable,*Annotation*
-keep class com.crashlytics.android.**
##--------------- other ----------
-dontwarn org.slf4j.LoggerFactory
-dontwarn org.slf4j.MDC
-dontwarn org.slf4j.MarkerFactory