Skip to main content

ProGuard | Xamarin Document Scanner

If you have ProGuard/R8 enabled for the release/production build, please make sure that Android SDK Tools package is installed inside your Android SDK Location and add the following rules:

For the Scanbot SDK for Xamarin

-keep public enum io.scanbot.sdk.barcode.entity.MSIPlesseyChecksumAlgorithm { *; }
-keep public enum io.scanbot.sdk.core.contourdetector.DetectionResult { *; }
-keep public enum io.scanbot.sdk.core.contourdetector.DetectionStatus { *; }
-keep public enum io.scanbot.check.model.CheckRecognizerStatus { *; }
-keep public enum io.scanbot.sdk.core.payformscanner.model.TokenType { *; }
-keep public enum io.scanbot.sdk.tiff.model.TIFFImageWriterCompressionOptions { *; }
-keep public enum io.scanbot.sdk.process.ImageFilterType { *; }

-keep public class io.scanbot.idcardscanner.IdScanResult { *; }
-keep class io.scanbot.genericdocument.entity.CommonFieldType { *; }
-keep class io.scanbot.genericdocument.entity.** { *; }
-keep class io.scanbot.genericdocument.** { *; }
-keep class androidx.appcompat.widget.FitWindowsLinearLayout { *; }
-keep class androidx.appcompat.widget.** { *; }
-keep class io.scanbot.barcodescanner.model.aamva.AAMVADocumentSubfile { *; }
-keep class io.scanbot.barcodescanner.model.** { *; }
-keep class io.scanbot.check.model.Result.** { *; }
-keep class io.scanbot.check.model.Result { *; }
-keep class io.scanbot.check.model.** { *; }

-keepattributes EnclosingMethod
-keepattributes InnerClasses
-keepattributes Signature
-keepattributes *Annotation*

-dontwarn sun.misc.**
-keep class com.google.gson.stream.** { *; }
-keep class * implements com.google.gson.TypeAdapter
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName <fields>;
}

For the native Scanbot SDK

v1.94.0+

ProGuard rules are integrated into the library and automatically applied to customer's modules.

But, customers who are using DexGuard tool for the obfuscation of the release application, have to add the following rules to the DexGuard configuration to keep the names of .so files unchanged for the Scanbot SDK:

-keepresourcefiles /lib/*/libscanbotsdk.so
-keepresourcefiles /lib/*/libtflite.so

-keepresourcefiles /lib/*/libscanbotsdkdata_gdr.so
-keepresourcefiles /lib/*/libscanbotsdkdata_docdetector.so
-keepresourcefiles /lib/*/libscanbotsdkdata_mcform.so
-keepresourcefiles /lib/*/libscanbotsdkdata_blurdetector.so
-keepresourcefiles /lib/*/libscanbotsdkdata_lcd.so
-keepresourcefiles /lib/*/libscanbotsdkdata_commonocr.so
-keepresourcefiles /lib/*/libscanbotsdkdata_ehic.so
-keepresourcefiles /lib/*/libscanbotsdkdata_ocrb.so
-keepresourcefiles /lib/*/libscanbotsdkdata_barcodev2.so
-keepresourcefiles /lib/*/libscanbotsdkdata_barcodev3.so
-keepresourcefiles /lib/*/libscanbotsdkdata_licenseplate.so

v1.74.0+

info

Since Scanbot SDK version 1.74.0 consumer ProGuard rules are integrated into the library and automatically applied to customers' modules.**

If you are using an older Scanbot SDK version you have to add these ProGuard rules for all Scanbot SDK Packages:

v1.73.x (or older)

-ignorewarnings

-keep public class io.scanbot.sdk.ui.** { *; }

-keep public class io.scanbot.sap.SapManager { *; }

-keeppackagenames io.scanbot.sdk.core.contourdetector.**
-keep public class io.scanbot.sdk.core.contourdetector.**{ *; }

-keeppackagenames com.googlecode.tesseract.android.**
-keep public class com.googlecode.tesseract.android.**{ *; }

-keeppackagenames io.scanbot.sdk.core.payformscanner.**
-keep public class io.scanbot.sdk.core.payformscanner.**{ *; }

-keeppackagenames io.scanbot.mrzscanner.**
-keep public class io.scanbot.mrzscanner.**{ *; }

-keeppackagenames io.scanbot.dcscanner.**
-keep public class io.scanbot.dcscanner.**{ *; }

-keeppackagenames io.scanbot.tiffwriter.**
-keep public class io.scanbot.tiffwriter.**{ *; }

-keeppackagenames io.scanbot.chequescanner.**
-keep public class io.scanbot.chequescanner.**{ *; }

-keeppackagenames io.scanbot.textorientation.**
-keep public class io.scanbot.textorientation.**{ *; }

-keeppackagenames io.scanbot.barcodescanner.**
-keep public class io.scanbot.barcodescanner.**{ *; }

-keeppackagenames io.scanbot.hicscanner.**
-keep public class io.scanbot.hicscanner.**{ *; }

-keeppackagenames io.scanbot.sdk.process.**
-keep public class io.scanbot.sdk.process.**{ *; }

-keeppackagenames io.scanbot.multipleobjectsscanner.**
-keep public class io.scanbot.multipleobjectsscanner.**{ *; }

-keeppackagenames io.scanbot.idcardscanner.**
-keep public class io.scanbot.idcardscanner.**{ *; }

-keeppackagenames io.scanbot.generictext.**
-keep public class io.scanbot.generictext.**{ *; }

-keeppackagenames io.scanbot.nfcscanner.passport.**
-keep public class io.scanbot.nfcscanner.passport.**{ *; }
-keep public class io.scanbot.nfcscanner.**{ *; }

# 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 this information.
-keepattributes Signature

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-dontwarn sun.misc.**
-keep class com.google.gson.stream.** { *; }

# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * implements com.google.gson.TypeAdapter
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer

# Prevent R8 from leaving Data object members always null
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName <fields>;
}

Want to scan longer than one minute?

Generate your free "no-strings-attached" Trial License and properly test the Scanbot SDK.

Get your free Trial License

What do you think of this documentation?