Configure Play Store distribution
Proguard Configuration
It's common for android apps to obfuscate the code when compiling the release apk, when doing this, you have to keep in mind all MobbScan classes that can't be obfuscated, in order to prevent this, your file proguard-rules.pro
, could look like this:
Standard proguard rules
-keepattributes *Annotation*, Exceptions, Deprecated, Signature, MethodParameters, InnerClasses
-keepparameternames
## Rules for EventBus (2.4.0)
-keepattributes *Annotation*
-keepclassmembers class * {
@org.greenrobot.eventbus.Subscribe <methods>;
}
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
# Only required if you use AsyncExecutor
-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
<init>(java.lang.Throwable);
}
## Rules for Tesseract
-keep class com.googlecode.tesseract.android.TessBaseAPI {
protected void onProgressValues(int, int, int, int, int, int, int, int, int);
}
## Rules for MobbScan
-dontwarn com.mobbeel.**
-dontwarn okio.mobbeel.**
-dontwarn org.opencv.**
-dontnote org.apache.http.**
-keep class com.mobbeel.** { *; }
## Rules for Gson
# Gson specific classes
-dontwarn sun.misc.**
-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
## MobbCommons rules
-dontwarn mobbeel.http.**
-dontwarn okio.mobbeel.**
-dontwarn javax.annotation.**
-dontwarn org.conscrypt.**
# A resource is loaded with a relative path so the package of this class must be preserved.
-keepnames class mobbeel.http.internal.publicsuffix.PublicSuffixDatabase
## Spognycastle rules
-keep class org.spongycastle.crypto.* {*;}
-keep class org.spongycastle.crypto.agreement.** {*;}
-keep class org.spongycastle.crypto.digests.* {*;}
-keep class org.spongycastle.crypto.ec.* {*;}
-keep class org.spongycastle.crypto.encodings.* {*;}
-keep class org.spongycastle.crypto.engines.* {*;}
-keep class org.spongycastle.crypto.macs.* {*;}
-keep class org.spongycastle.crypto.modes.* {*;}
-keep class org.spongycastle.crypto.paddings.* {*;}
-keep class org.spongycastle.crypto.params.* {*;}
-keep class org.spongycastle.crypto.prng.* {*;}
-keep class org.spongycastle.crypto.signers.* {*;}
-keep class org.spongycastle.jcajce.provider.** { *; }
-keep class org.spongycastle.jcajce.provider.digest.** {*;}
-keep class org.spongycastle.jcajce.provider.keystore.** {*;}
-keep class org.spongycastle.jcajce.provider.symmetric.** {*;}
-keep class org.spongycastle.jcajce.spec.* {*;}
-keep class org.spongycastle.jce.** {*;}
## Bouncycastle rules
-keep class org.bouncycastle.crypto.* {*;}
-keep class org.bouncycastle.crypto.agreement.** {*;}
-keep class org.bouncycastle.crypto.digests.* {*;}
-keep class org.bouncycastle.crypto.ec.* {*;}
-keep class org.bouncycastle.crypto.encodings.* {*;}
-keep class org.bouncycastle.crypto.engines.* {*;}
-keep class org.bouncycastle.crypto.macs.* {*;}
-keep class org.bouncycastle.crypto.modes.* {*;}
-keep class org.bouncycastle.crypto.paddings.* {*;}
-keep class org.bouncycastle.crypto.params.* {*;}
-keep class org.bouncycastle.crypto.prng.* {*;}
-keep class org.bouncycastle.crypto.signers.* {*;}
-keep class org.bouncycastle.jcajce.provider.** { *; }
-keep class org.bouncycastle.jcajce.provider.digest.** {*;}
-keep class org.bouncycastle.jcajce.provider.keystore.** {*;}
-keep class org.bouncycastle.jcajce.provider.symmetric.** {*;}
-keep class org.bouncycastle.jcajce.spec.* {*;}
-keep class org.bouncycastle.jce.** {*;}
-dontwarn javax.naming.**
-keep class net.sf.scuba.smartcards.** { public *; }
Video steps proguard rules
If you integrate MobbScan-Video-Android dependency, you will also need these rules:
## Rules for Twilio
-keep class tvi.webrtc.** { *; }
-keep class org.webrtc.** { *; }
-keep class com.twilio.video.** { *; }
-keepattributes InnerClasses
NFC proguard rules
If you integrate MobbScan-NFC-Extension-Android dependency, you will also need these rules:
## NFC rules
-dontwarn de.tsenger.androsmex.**
-dontwarn jj2000.**
-dontwarn java.awt.**
-dontwarn com.fasterxml.jackson.**
-dontwarn javax.**
Arquitectures compilation
If you want to reduce the size of your final SDK you could do it by having different libraries for different architectures. To do it you can add abiFilters on your build.gradle
:
...
android {
...
productFlavors {
x86 {
ndk {
abiFilter "x86"
}
}
arm {
ndk {
abiFilters "armeabi-v7a", "armeabi"
}
}
}
...
}
...
Or in your buildTypes
:
...
android {
...
buildTypes {
debug {
debuggable true
minifyEnable false
ndk {
abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86_64"
}
}
release {
debuggable false
minifyEnabled false
ndk {
abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
}
}
}
...
}
...