Android Barcode Scanner SDK

Run offline 1D and 2D barcode scanning inside your Android mobile app. Add one MIT-licensed AAR from JitPack, decode 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 camera capture or a 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")
}

Need 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 licence

    MIT

Run offline barcode scanning in your Android app

Decode retail, warehouse and 2D matrix labels locally on Android devices without Google Play Services or external lookup requests.

Read label images

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

Run off the main thread

Execute 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 remain intact, then query your own inventory or product database.

Set up barcode image reading in Kotlin on Android

Configure 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 declare the single-line dependency for the Android library on JitPack. Omit any leading v prefix from the version string.

The AAR ships 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, making JitPack the active distribution 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 required.

Java projects add the exact same Gradle dependency and invoke 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 parse the returned ScanReport JSON leniently. This function retains eight common barcode symbologies (Code 128, Code 39, EAN-13, EAN-8, UPC-A, UPC-E, ITF and Data Matrix) and excludes 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 sample, 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 parameter sets the scan profile: "frame" decodes without computing a scannability score; switch to "full" for worn or low-contrast label photos.

Always check report.trace.budget_exhausted: an empty detections list is a final “no barcode found” result 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 value such as 012345678905 keeps its leading zero intact as a String.

A blank image or one containing 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 no Play Services dependency.

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

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

Android Barcode Scanner documentation and licence

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-licensed Android library (AAR) for decoding 1D and 2D barcodes (plus QR codes) directly on Android devices. Built from the shared Rust engine via UniFFI, it returns the standard ScanReport JSON string while your app controls the camera, picker and inventory flow.

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

It decodes 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 map to ean13, code128 and itf.

Yes. Both Kotlin and Java Android apps can consume the AAR. It packages 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 alongside its detected symbology (plus parsed GS1 fields when recognised). Keep identifiers as strings so leading zeros stay intact, and query your own product catalogue or inventory database for item details.

scan() executes synchronously inside the native Rust library. Calling it on 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 calls, no QR Code AI account, no API key and no creation credits.

Yes. Current releases of the engine and Android binding carry the MIT licence, allowing commercial and proprietary use while retaining copyright and licence 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.