Skip to main content

Initializing the Kotlin Multiplatform Document Scanner SDK

Free Developer Support

We provide free technical support for the implementation and 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 send us an email.

SDK initialization

The Scanbot Document Scanner SDK must be initialized before usage. For Kotlin Multiplatform applications, we recommend initializing the SDK as early as possible during your app's runtime to ensure the SDK is correctly initialized even if the app's process is restored by the operating system after being terminated in the background.

Basic initialization

To initialize the SDK, use the ScanbotSDK.initialize() method with a SdkConfiguration object:

SDK initialization imports
loading...
Basic initialization
loading...

Setting the license key

info

You can use the Scanbot Document Scanner SDK for quick testing or evaluation purposes even without a license key. However, the SDK will only work for 60 seconds per app session and may not be used for production purposes. Want to scan longer than 60 seconds? Get your free trial license key at the Scanbot trial page.

Setting license key
loading...

License key binding

The Scanbot SDK license key is bound to your application's bundle identifier:

  • Android: The applicationId found in your app-level build.gradle file
  • iOS: The Bundle Identifier in your Xcode project
info

Please make sure that you have inserted the exact key as it was provided by us, including all encoded line breaks \n.

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 runtime via licenseInfo.isValid. If this property returns false, you should disable any usage of the Scanbot SDK (functions, UI components, etc).

Android registration

info

This step is required on Android only. iOS does not require any additional registration.

On Android, the SDK requires an additional registration step before any API calls are made.

With Ready-to-Use UI (RTU)

If you are using the Ready-to-Use UI components, register the Activity in androidMain/MainActivity.kt:

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)

ScanbotSDK.registerActivity(this)
setContent {
App()
}
}
}

Without Ready-to-Use UI (low-level API only)

If you are using only the low-level SDK APIs without any RTU UI components, registering the Application instance is sufficient:

ScanbotSDK.registerApplication(application)
caution

ScanbotSDK.registerActivity(this) or ScanbotSDK.registerApplication(application) must always be called before ScanbotSDK.initialize(...). Calling initialize without prior registration on Android will result in incorrect SDK behavior.

Checking license status

You can retrieve the current license information at any time:

Checking license status
loading...

Configuration options

The SdkConfiguration class provides several options to customize SDK behavior:

Logging

Enable detailed logging for debugging purposes:

Enable SDK logging
loading...
  • loggingEnabled: Enables SDK logging (default: false)
  • enableNativeLogging: Enables Scanbot SDK Core native logging on Android (default: false)

Control detection acceleration and optimizations (Android only)

info

All acceleration and optimization options described in this section apply to Android only and have no effect on iOS.

The SDK provides several options to manage detection performance on Android devices. These options allow you to fine-tune the balance between performance, battery consumption, and compatibility.

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 detection, you can disable this option:

Disable XNNPACK acceleration
loading...

GPU acceleration

Allows accelerating ML models using the GPU of the mobile device. By default, it is enabled. To disable it:

Disable GPU acceleration
loading...

If you experience issues with GPU acceleration on certain devices, you can disable it using this flag.

Performance Hint API

The Performance Hint API increases performance by utilizing top CPU cores on Android devices, which may result in increased battery usage:

Performance hint
loading...

Example: Disabling all Android optimizations

If you experience compatibility issues or want to minimize battery usage, you can disable all Android-specific optimizations:

Disable all optimizations
loading...

Want to scan longer than one minute?

Generate a free trial license to test the Scanbot SDK thoroughly.

Get free trial license