Add the SDK to Your App
This guide shows you how to add the Scandit Data Capture SDK to current existing project.
Prerequisites
The latest stable version of the Android SDK (for example through the latest Android Studio).
An Android project with target SDK version 23 (Android 6, Marshmallow) or higher.
A valid Scandit Data Capture SDK license key. You can sign up for a free test account at ssl.scandit.com.
Note
Devices running the Scandit Data Capture SDK need to have a GPU or the performance will drastically decrease.
Get a License Key
If you have a paid subscription, please reach out to support@scandit.com if you need a new license key.
Add the SDK
Scandit Data Capture SDK is distributed as AAR libraries in the official Scandit maven repository.
You will always need to add a reference to com.scandit.datacapture:core, which contains the shared functionality used by the other data capture modules. If you’re using textcapture-related functionalities, make sure to also add a reference to com.scandit.datacapture:text-base. In addition, depending on the data capture task, you will need a reference to:
com.scandit.datacapture:barcode (ScanditBarcodeCapture API) if you want to use barcode-related functionality such as barcode capture or MatrixScan.
com.scandit.datacapture:parser (ScanditParser API) if you want to parse data strings, e.g. as found in barcodes, into a set of key-value mappings.
com.scandit.datacapture:text (ScanditTextCapture API) if you want to use text recognition (OCR) functionality, often combined with barcode scanning to deliver simultaneous barcode and text capture.
com.scandit.datacapture:id (ScanditIdCapture API) if you want to scan personal identification documents such as identity cards, passports or visas.
You can safely remove barcode, parser, text or id dependencies if you are not going to use their features.
Gradle
Add mavenCentral() repository in build.gradle file:
repositories {
mavenCentral()
}
Add the necessary artifacts as dependencies to the app’s build.gradle:
dependencies {
implementation "com.scandit.datacapture:core:[version]"
implementation "com.scandit.datacapture:barcode:[version]"
implementation "com.scandit.datacapture:parser:[version]"
implementation "com.scandit.datacapture:text-base:[version]"
implementation "com.scandit.datacapture:text:[version]"
implementation "com.scandit.datacapture:id:[version]"
}
Latest [version] is 6.21.0-beta.3 and can be found on Sonatype.
Note
The core module depends on okhttp version 4.9.2. If your project already implements a different version of okhttp (within the supported version range specified in the requirements page), make sure to exclude the group from the gradle implementation of the core module.
implementation("com.scandit.datacapture:core:[version]") {
exclude group: "com.squareup.okhttp3"
}
Maven
Add the mavenCentral repository in pom.xml file:
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Maven Central</name>
<url>https://repo1.maven.org/maven2</url>
</repository>
</repositories>
Add the necessary artifacts as dependencies:
<dependency>
<groupId>com.scandit.datacapture</groupId>
<artifactId>core</artifactId>
<version>[version]</version>
</dependency>
<dependency>
<groupId>com.scandit.datacapture</groupId>
<artifactId>barcode</artifactId>
<version>[version]</version>
</dependency>
<dependency>
<groupId>com.scandit.datacapture</groupId>
<artifactId>parser</artifactId>
<version>[version]</version>
</dependency>
<dependency>
<groupId>com.scandit.datacapture</groupId>
<artifactId>text-base</artifactId>
<version>[version]</version>
</dependency>
<dependency>
<groupId>com.scandit.datacapture</groupId>
<artifactId>text</artifactId>
<version>[version]</version>
</dependency>
<dependency>
<groupId>com.scandit.datacapture</groupId>
<artifactId>id</artifactId>
<version>[version]</version>
</dependency>
Manually Add the Library to your Project
You will always need to add a reference to ScanditCaptureCore.aar, which contains the shared functionality used by the other data capture modules. In addition, depending on the data capture task, you will need a reference to:
ScanditBarcodeCapture API if you want to use barcode-related functionality such as barcode capture or MatrixScan.
ScanditParser API if you want to parse data strings, e.g. as found in barcodes, into a set of key-value mappings.
ScanditTextCapture API if you want to use text recognition (OCR) functionality, often combined with barcode scanning to deliver simultaneous barcode and text capture.
ScanditIdCapture API if you want to scan personal identification documents such as identity cards, passports or visas.
If your project already has a local flatDir repository, add the AAR files to that folder. If you do not have a flatDir respository yet, create a new one in your build.gradle file as illustrated below:
repositories {
flatDir {
dirs '/path/to/folder/containing/the/aar/file'
}
}
Add the .aar libraries as dependencies to your build.gradle file (below an example with BarcodeCapture and TextCapture)
dependencies {
api(name:'ScanditBarcodeCapture', ext:'aar')
api(name:'ScanditTextCaptureBackend', ext:'aar')
api(name:'ScanditTextCapture', ext:'aar')
}
External dependencies
The Scandit Data Capture SDK modules depend on a few standard libraries that you can find listed below. If you are including the Scandit Data Capture SDK through Gradle or Maven, all of these dependencies are automatically pulled in and there is no need for you to do anything further. If on the other hand you are directly adding the AAR files to the project, you will have to add these dependencies yourself.
Module |
Dependencies |
---|---|
ScanditCaptureCore.aar |
|
ScanditBarcodeCapture.aar |
|
ScanditParser.aar |
No dependencies |
ScanditTextCapture.aar |
|
ScanditIdCapture.aar |
|
Additional Information
Note
If you’re using androidx.fragments dependency and have the situation where a scanning fragment navigates to another scanning fragment with an incompatible mode, make sure you’re using version 1.3.0+ of the dependency. If not, you may run into an incompatible modes error, as the new fragment gets resumed before the previous is paused and for some time incompatible modes may be enabled in the DataCaptureContext at the same time. This results in sessions being empty of any result.
Note
On Android, the Scandit SDK uses content providers to initialize the scanning capabilities properly. If your own content providers depend on the Scandit SDK, choose an initOrder lower than 10 to make sure the SDK is ready first.
If not specified, initOrder is zero by default and you have nothing to worry about.
Next steps
To add single barcode scanning to your app:
Get started with SparkScan, our pre-built component for high speed scanning.
Get started with Barcode Capture, the fully-flexible API for single scanning.
Get started with Barcode Selection, our pre-built solution for selection of one of many codes.
To add ID scanning to your app:
To add multi-barcode scanning to your app:
Get started with MatrixScan Find for AR-guided search.
Get started with MatrixScan Count for batch scanning and counting.
Get started with MatrixScan, our fully flexible API for multi-code scanning.