Skip to main content

Building Production Apps | Flutter Document Scanner

Building Production Apps

iOS

The Scanbot SDK iOS Framework (included in this Flutter Plugin) contains 64-bit architectures (arm64, x86_64). You can thus run it on all commonly used iOS devices as well as on simulators during the development phase. To be able to submit a production build to the App Store or a test build for TestFlight you have to remove (strip away) the architectures x86_64 and i386 from the Scanbot SDK Framework. These architectures are only for simulators and not allowed to be submitted to iTunes Connect.

Android

The Scanbot Android SDK uses native libraries under the hood and supports the following ABIs: armeabi-v7a, arm64-v8a, x86 and x86_64.

By default the native libraries of all these architectures will be included in the app package (APK), which will result in a large APK file. Please consider removing support for x86 and x86_64 architectures. In most cases both "x86" architectures can be removed for the release (production) build, since they are only used on emulators and on some rare devices with the Intel Atom architecture.

To exclude certain ABIs from the APK, use the abiFilters property in the android/app/build.gradle file of your project:

android {
...
defaultConfig {
...
ndk {
abiFilters "armeabi-v7a", "arm64-v8a"
// Please add "x86" and "x86_64" if you would like to test on an emulator
// or if you need to support some rare devices with the Intel Atom architecture.
}
}
}

In this example we defined abiFilters for armeabi-v7a and arm64-v8a, so x86 and x86_64 architectures will be excluded.

💡 However, if you need to support all architectures and would also like to optimize the APK size, we highly recommend checking out the Android App Bundle approach. It allows you to create and distribute dedicated, smaller APKs via the PlayStore (basically, it is similar to the iOS App Store approach).

ProGuard

Default Flutter rules

-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }
-dontwarn io.flutter.embedding.**
-ignorewarnings
-dontoptimize

For the Scanbot SDK Flutter Plugin

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

-keepclassmembers enum io.scanbot.sdk.** { *; }

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

-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 io.scanbot.sdk.contourdetector.**
-keep public class io.scanbot.sdk.contourdetector.**{ *; }
#
-keeppackagenames com.googlecode.tesseract.android.**
-keep public class com.googlecode.tesseract.android.**{ *; }

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

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

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

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

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

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

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

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?