Skip to main content

SDK Initialization | Android Document Scanner

License Key

In order to run the Scanbot SDK within your production app, you must purchase and use a valid Scanbot SDK license.

Each license key is valid only for a given app bundle identifier. You will be unable to use any of the SDK features if the license key is corrupted, expired, or invalid in any other way.

Trial License

The Scanbot SDK will run without a license for one minute per session! To get a free, "no-strings-attached" 7-day trial license, please submit the Trial License Form on our website.

Please kindly note that a trial license can only be used in a development and staging environment. You are not allowed to publish your app to the App Store, Play Store, or any 3rd party Android App Store with a trial license.

Purchase a Production License

To get pricing information and purchase a production license for the Scanbot SDK please request a quote.

Initialize

Free Developer Support

We provide free "no-strings-attached" developer support for the implementation & testing of the Scanbot SDK. If you encounter technical issues with integrating the Scanbot SDK or need advice on choosing the appropriate framework or features, please visit our Support Page.

The Scanbot SDK must be initialized before usage. Add the following code snippets to your Application class:

import io.scanbot.sdk.ScanbotSDKInitializer

class Application : Application() {

override fun onCreate() {
super.onCreate()

ScanbotSDKInitializer()
.license(this, LICENSE_KEY) // see below
.initialize(this)
}
}

Don't forget to register the application class in AndroidManifest.xml:

<application
...
android:name=".Application"
...

Please make sure to use the ScanbotSDKInitializer class from the new Java package io.scanbot.sdk.

caution

Unfortunately, we have noticed that all devices using a Cortex A53 processor DO NOT SUPPORT GPU acceleration. If you encounter any problems, please disable GPU acceleration for these devices.

ScanbotSDKInitializer()
.allowGpuAcceleration(false)

Add Scanbot SDK License Key

Use the method license(application, "YOUR_SCANBOT_SDK_LICENSE_KEY") on initialization of the Scanbot SDK to set your license key:

// This is an expired license key. Used only for demo code purposes!
const val LICENSE_KEY =
"MiKudIf/IFGnwk/0ZQAhx58IGEV8/L" +
"d6dF/F/j2TyLNNb+TCaIsQLOf2+/Ih" +
"LRRPvRsHESA/b0KFqnxYl4briv3kzQ" +
"tSTrvDJ9mE15rxU/Pob4XRnjTSc9B7" +
"P/CpM0HDkmM02U8ljt0kKwpQSRZkiz" +
"rBe+qttmA0b00ZEcyfn9t2xP4zRdaD" +
"ayjWAdZi82oP3UST3bLIV8I90Qordf" +
"s+u23JKL52bQY+HB1HNW7Ow8rA4+Mg" +
"Lr/wE2N+UBElHPOZLtQBTHYUvbVwVU" +
"KZDWOEv8VfrTmn2XA0tKVSDaxL6z7B" +
"1s2g83XWYaxXrf4A3q/fkSNvDN1oic" +
"Dvs0gbD1Lf0w==\nU2NhbmJvdFNESw" +
"ppby5zY2FuYm90LmV4YW1wbGUuc2Rr" +
"LmFuZHJvaWQKMTQ3ODA0NDc5OQoyCj" +
"I=\n"

ScanbotSDKInitializer()
.license(this, LICENSE_KEY)
.initialize(this)

The Scanbot SDK license key is bound to the applicationId, which can be found in the app-level build.gradle file of your app. Please note that the applicationId is the actual and relevant ID of an app. The "package" in the AndroidManifest.xml as well as the Java package are NOT relevant (also see the Android documentation).

Please make sure that you have inserted the exact key as it is stated in the license file - with all encoded line breaks \n.

License Checks in Production Apps

caution

If your Scanbot SDK license has expired, any call to the Scanbot SDK API will return empty results. To prevent this you should always check for license expiration during the runtime via licenseInfo.isValid. If this property returns false, you should disable any usage of the Scanbot SDK (functions, UI components, etc).

To handle License errors properly the IScanbotSDKLicenseErrorHandler can be used. The callback will be triggered if any license error has occurred. Use the following snippet to initialize Scanbot with a callback.

import io.scanbot.sdk.ScanbotSDK

ScanbotSDKInitializer()
.withLogging(true)
.license(this, LICENSE_KEY)
.licenceErrorHandler(IScanbotSDKLicenseErrorHandler { status, feature, message ->
// Handle license errors here:
LoggerProvider.logger.d("ExampleApplication", "license status:${status.name}, message: $message")
if (feature != SdkFeature.NoSdkFeature) {
LoggerProvider.logger.d("ExampleApplication", "Missing SDK feature in license: ${feature.name}")
}
})
.initialize(this)

We highly recommend implementing a suitable handling of this case in your app!

Example code for checking the license status:

import io.scanbot.sdk.ScanbotSDK

// Check the license status:
val licenseInfo = ScanbotSDK(activity).licenseInfo
LoggerProvider.logger.d("ExampleApplication", "License status: ${licenseInfo.status}")
LoggerProvider.logger.d("ExampleApplication", "License isValid: ${licenseInfo.isValid}")
LoggerProvider.logger.d("ExampleApplication", "License message: ${licenseInfo.licenseStatusMessage}")

if (licenseInfo.isValid) {
// Making your call into ScanbotSDK API is now safe.
// e.g. start barcode scanner
}

Storage encryption

The Scanbot SDK provides the ability to encrypt all stored images and PDF files in the SDK app folder.

Please note

Encryption is not enabled by default.

Please see more details here.

Control detection acceleration and optimizations

There are a few options developers can use to manage the SDK's detection performance.

  • Xnnpack acceleration - setting Xnnpack acceleration for ML models provides highly-optimized implementations of floating-point neural network operators and can improve performance up to 4x. It is enabled by default and only disabled for models that have shown problems during testing. If you encounter any problems with the detection you could try to disable this option by setting:
ScanbotSDKInitializer()
.allowXnnpackAcceleration(false)
...
.initialize(this)
  • GpuAcceleration - allows accelerating ML models using the GPU of the mobile device. By default it is enabled. To disable it set:
ScanbotSDKInitializer()
.allowGpuAcceleration(false)
...
.initialize(this)
  • Precompilation of the GPU ML models - allows to precompile ML model data thus speeding up the second and subsequent scanner initializations, but as a downfall the initial start of the scanner will be quite slow. It is disabled by default but can be enabled by setting:
ScanbotSDKInitializer()
.precompileGpuMlModels(precompilingCallback)
...
.initialize(this)

Where:

  • precompilingCallback is a lambda that will be triggered when GPU ML models compilation has completed.

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?