On this page

Stuck? Open a support ticket and the barKoder team will help. Open a ticket

Android Installation

1. Add the package #

Way 1: the barkoder module (Groovy DSL) #

Download the Android SDK package from Downloads in the barKoder Developer Portal and unzip it. In Android Studio, choose File › New › Import Module and pick its barkoder folder: the one that holds both barkoder.aar and build.gradle, not the barkoder.aar file.

Import barKoder as module in Groovy DSL
Import barKoder as module in Groovy DSL

Add Dependency #

In your app's build.gradle, add the dependency:

Add dependency for barKoder
Add dependency for barKoder
Kotlin
implementation project(path: ':barkoder')

Way 2: the AAR file (Kotlin DSL) #

Or put the AAR file itself in your app (for projects with Kotlin DSL Gradle files):

Create a libs folder in your app directory #

<br>

Put barkoder.aar in libs folder #

<br>

Add to build.gradle.kts (Module :app): #

Gradle
implementation(files("libs/barkoder.aar"))

2. Add the scanner view #

Add Activity/Fragment #

In the layout of the activity or fragment that shows the scanner, add the view:

Add activity/fragment
Add activity/fragment
XML-DOC
<com.barkoder.BarkoderView
        android:id="@+id/bkdView"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

3. Set the license key and barcode types #

Licensing #

Without a valid license key the SDK still scans, but each result starts with (Unlicensed) and part of its data is replaced with dots. Get a free trial key on the trial page: choose Native or WASM and enter your app ID (for the Web SDK, your domain). A trial key lasts 30 days, for up to 25 devices, one per app ID. For a production license, request a quote. By using the SDK you agree to the End User License Agreement.

Create Barkoder Config #

In your activity, set the config with your license key. The template sets the other settings for one kind of use, here industrial 1D barcodes:

Kotlin
bkdView.config = BarkoderConfig(this, "LICENSE_KEY") {
   Log.i("LicenseInfo", it.message)
}
BarkoderHelper.applyConfigSettingsFromTemplate(
   this,
   bkdView.config,
   BarkoderConfigTemplate.INDUSTRIAL_1D,
   null
)

Enabling Symbologies #

Turn on the barcode types you scan, all at once or one by one:

Kotlin
private fun setActiveBarcodeTypes() {
    // There is option to set multiple active barcodes at once as array
    bkdView.config.decoderConfig.SetEnabledDecoders(
        arrayOf(
            Barkoder.DecoderType.QR,
            Barkoder.DecoderType.Ean13,
            Barkoder.DecoderType.IDDocument // enable mrz
        )
    )
    // or configure them one by one
    bkdView.config.decoderConfig.UpcA.enabled = true
}

4. Start scanning and read results #

Add BarkoderResultCallback #

Each result comes to scanningFinished. Add BarkoderResultCallback to your activity:

Kotlin
class MainActivity : AppCompatActivity(), BarkoderResultCallback {
   ....

   override fun scanningFinished(results: Array<Barkoder.Result>, thumbnails: Array<Bitmap>?, imageResult: Bitmap?) {
       Log.i("Scanned result", results.firstOrNull()?.textualData ?: "nothing read")
   }
}

Start Scanning #

Finally, start scanning, for example from a Scan button. The first time, the SDK asks the user for the camera permission (it is already in the SDK's manifest):

Kotlin
bkdView.startScanning(this)