Android Barcode Scanner SDK

Add offline 1D and 2D barcode scanning to your Android app. Install one MIT-licensed AAR from JitPack, pass label image bytes off the main thread and return each identifier with its detected symbology.

Kotlin
import org.json.JSONObject
import uniffi.qrcode_ai_scanner_uniffi.scan

val report = JSONObject(scan(imageBytes, "frame"))
val rows = report.getJSONArray("detections")
val barcode = (0 until rows.length()).map { rows.getJSONObject(it) }
    .firstOrNull { it.getString("symbology") == "code128" }

println(barcode?.getJSONObject("content")?.getString("text"))

Inspect the decoded identifierSTOCK-4827

Read label images

Pass encoded PNG, JPEG, WebP or GIF bytes from a camera capture or file picker to scan(). A Code 128 label encoding STOCK-4827 returns that exact string.

// settings.gradle.kts
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        maven { url = uri("https://jitpack.io") }
    }
}

// app/build.gradle.kts
dependencies {
    implementation("com.github.qrcode-ai-com:qrcode-barcode-scanner:0.12.2")
}

Want to scan a barcode now? Open the online reader

Android Barcode Scanner SDK at a glance

  • One-line Gradle dependency

    JitPack AAR

  • Page-aligned native libraries

    4 ABIs · 16 KB

  • EAN, UPC, Code 128, Data Matrix & more

    1D + 2D

  • Open-source license

    MIT

Bring offline barcode scanning into your Android app

Decode retail, warehouse and 2D matrix labels directly on Android hardware without Google Play Services or external lookup calls.

Read label images

Pass encoded PNG, JPEG, WebP or GIF bytes from a camera capture or file picker to scan(). A Code 128 label encoding STOCK-4827 returns that exact string.

Run off the main thread

Invoke the synchronous native UniFFI call on Dispatchers.Default so inventory lists, forms and camera previews stay responsive.

Keep exact strings & formats

Read each detection’s symbology and content.text as a String so leading zeros survive, then query your own inventory or product database.

Add barcode image reading in Kotlin on Android

Add the JitPack repository, depend on the Android AAR and return barcode identifiers with their symbology off the main thread.

Add the Android AAR from JitPack

Add JitPack to your Gradle repositories, then add the single-line dependency for the Android library on JitPack. Use the version string without a leading v prefix.

The AAR bundles native libraries for four Android ABIs (arm64-v8a, armeabi-v7a, x86_64 and x86) with 16 KB page alignment on 64-bit targets. Maven Central is not published yet, so JitPack is the live coordinate today.

// settings.gradle.kts
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        maven { url = uri("https://jitpack.io") }
    }
}

// app/build.gradle.kts
dependencies {
    implementation("com.github.qrcode-ai-com:qrcode-barcode-scanner:0.12.2")
}

Current releases resolve JNA’s Android AAR cleanly with this single dependency line; no manual JNA exclusion is needed.

Java projects add the exact same Gradle dependency and call the generated UniFFI class from a background executor.

Decode a barcode image off the main thread

Import scan from uniffi.qrcode_ai_scanner_uniffi, call it on Dispatchers.Default and decode the returned ScanReport JSON leniently. This function keeps eight common barcode symbologies (Code 128, Code 39, EAN-13, EAN-8, UPC-A, UPC-E, ITF and Data Matrix) and filters out QR codes. Add other symbology names such as pdf417, aztec, code93, codabar, data_bar or data_bar_expanded as needed.

To prepare a known test label, create a Code 128 barcode with Barcode Generator containing STOCK-4827 and test the exported PNG in your app.

Kotlin
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
import uniffi.qrcode_ai_scanner_uniffi.scan

@Serializable
data class ScanReportDto(
    val detections: List<DetectionDto> = emptyList(),
    val trace: TraceDto = TraceDto()
)

@Serializable
data class DetectionDto(
    val symbology: String,
    val content: ContentDto
)

@Serializable
data class ContentDto(
    val text: String,
    val raw: String,
    val charset: String = "utf8"
)

@Serializable
data class TraceDto(
    val budget_exhausted: Boolean = false
)

data class BarcodeReading(val symbology: String, val text: String)

private val barcodeFormats = setOf(
    "code128", "code39", "ean13", "ean8",
    "upc_a", "upc_e", "itf", "data_matrix"
)
private val reportJson = Json { ignoreUnknownKeys = true }

suspend fun readBarcodeImage(imageBytes: ByteArray): List<BarcodeReading> =
    withContext(Dispatchers.Default) {
        val rawJson: String = scan(imageBytes, "frame")
        val report = reportJson.decodeFromString<ScanReportDto>(rawJson)
        report.detections
            .filter { it.symbology in barcodeFormats && it.content.charset != "unknown" }
            .map { BarcodeReading(it.symbology, it.content.text) }
    }

The second argument selects the scan profile: "frame" decodes without computing a scannability score; switch to "full" for difficult or low-contrast label photos.

Always check report.trace.budget_exhausted: an empty detections list is a final “no barcode found” outcome only when budget_exhausted is false.

Inspect the decoded identifier

For a Code 128 label encoding STOCK-4827, readBarcodeImage returns BarcodeReading(symbology = "code128", text = "STOCK-4827"). A UPC-A code such as 012345678905 keeps its leading zero intact as a String.

A blank image or one holding only QR codes returns an empty list. An unreadable or unsupported file throws a UniFFI exception: catch it around scan() and clear stale UI values.

Android architecture, barcode formats and report handling

Native AAR and ABIs. Ships Kotlin/Java UniFFI bindings (uniffi.qrcode_ai_scanner_uniffi, namespace studio.supernovae.qrcodeaiscanner) for arm64-v8a, armeabi-v7a, x86_64 and x86 with 16 KB page alignment and zero Play Services.

Identifiers and JSON decoding. Decodes 16 barcode formats plus QR (ISBN → ean13, GS1-128 → code128, ITF-14 → itf); keep values as strings to preserve leading zeros. Your app owns CameraX capture and parses ScanReport with ignoreUnknownKeys = true.

Distribution and MIT license. Current releases are MIT-licensed (with Apache-2.0 notices in LICENSING.md) and live on JitPack; Maven Central is not published yet. See the Kotlin binding README for local cargo-ndk builds.

Android Barcode Scanner documentation and license

Binding documentation, ScanReport schema and licensing references on GitHub.

Android Barcode Scanner SDK questions

Gradle setup, JitPack, formats, CameraX, threading, offline use and licensing.

It is QR Code AI’s open-source MIT Android library (AAR) for decoding 1D and 2D barcodes (and QR codes) directly on Android devices. Generated from the shared Rust engine via UniFFI, it returns the standard ScanReport JSON string while your app controls the camera, picker and inventory workflow.

It is live on JitPack under com.github.qrcode-ai-com:qrcode-barcode-scanner (use the release number without a v prefix). It is not published on Maven Central yet, so add https://jitpack.io to your Gradle repositories.

It reads 16 barcode formats: EAN-13, EAN-8, UPC-A, UPC-E, Code 128, Code 39, Code 93, Codabar, ITF, Telepen, GS1 DataBar, GS1 DataBar Expanded, Data Matrix, PDF417, Aztec and MaxiCode, plus QR Code, Micro QR and rMQR. ISBN, GS1-128 and ITF-14 return ean13, code128 and itf.

Yes. Both Kotlin and Java Android apps can depend on the AAR. It bundles native libraries for arm64-v8a, armeabi-v7a, x86_64 and x86, and all 64-bit native binaries are aligned to 16 KB memory pages.

No. The scanner returns each encoded identifier and its detected symbology (plus parsed GS1 fields when recognized). Preserve identifiers as strings so leading zeros stay intact, and query your own inventory or product database for item details.

scan() runs synchronously inside the native Rust library. Calling it from Dispatchers.Default (or a background Executor in Java) keeps Android UI rendering and camera previews responsive.

No. Decoding runs locally inside the native libraries packaged in your APK or App Bundle, with no Google Play Services dependency, no hosted API call, no QR Code AI account and no creation credits.

Yes. Current releases of the engine and Android binding are published under the MIT license, permitting commercial and proprietary use while retaining copyright and license notices (see LICENSING.md for third-party Apache-2.0 notices). SDK use is separate from QR Code AI’s paid creation plans and seven-day Premium trial.