Android QR Code Scanner SDK

Add offline QR code scanning to your Android mobile app. Install one MIT-licensed AAR from JitPack, pass image bytes off the main thread and receive decoded URLs, text and QR quality diagnostics on the device.

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

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

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

Inspect the decoded resulthttps://qrcode-ai.com/

Read saved QR images

Pass encoded PNG, JPEG, WebP or GIF bytes from Android’s photo picker, camera capture or local storage to scan() and receive exact decoded text.

// 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 code straight away? Open the online reader

Android QR Code Scanner SDK at a glance

  • One-line Gradle dependency

    JitPack AAR

  • Page-aligned native libraries

    4 ABIs · 16 KB

  • No Google Play Services needed

    On-device

  • Open-source licence

    MIT

Bring offline QR scanning into your Android app

Bundle the native Rust engine inside your APK or App Bundle and retain full control over camera UI, permissions and result actions.

Read saved QR images

Pass encoded PNG, JPEG, WebP or GIF bytes from Android’s photo picker, camera capture or local storage to scan() and receive exact decoded text.

Run off the main thread

Execute the synchronous native UniFFI call inside a Kotlin coroutine on Dispatchers.Default so scrolling, animations and camera preview stay smooth.

Parse the JSON report

Read each detection’s symbology, content.text, structured payload and optional scannability score from the cross-platform ScanReport JSON string.

Add QR image reading in Kotlin on Android

Add the JitPack repository, depend on the Android AAR and decode image bytes 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 invoke the generated UniFFI class from a background executor.

Decode a QR image off the main thread

Import scan from uniffi.qrcode_ai_scanner_uniffi, invoke it on Dispatchers.Default and decode the returned ScanReport JSON leniently so additive fields never break your parser. This example keeps regular QR code detections (qr_code) and preserves raw fallback awareness when content.charset is unknown.

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
)

private val reportJson = Json { ignoreUnknownKeys = true }

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

The second argument selects the scan profile: "full" (deepest preprocessing plus QR scannability score), "fast" (lighter scoring) or "frame" (decoding only, score is null).

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

Inspect the decoded result

For a QR image encoding https://qrcode-ai.com/, readQrImage returns ["https://qrcode-ai.com/"]. Display the decoded string in your Android UI and let the user decide whether to copy it or open a browser intent.

An image without a QR code returns an empty list rather than throwing. An unreadable or unsupported file throws a UniFFI exception: catch it around scan() and clear any previous result.

Android architecture, camera capture 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 Google Play Services dependency.

Camera and JSON decoding. Your app owns CameraX/Camera2 capture and runtime permissions. Parse ScanReport leniently with Json { ignoreUnknownKeys = true }, and inspect content.charset / content.raw when raw bytes matter.

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

Android QR Code Scanner documentation and licence

Binding documentation, ScanReport schema and licensing references on GitHub.

Android QR Code Scanner SDK questions

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

It is QR Code AI’s open-source MIT-licensed Android library (AAR) for decoding QR codes, Micro QR, rMQR and 16 barcode formats directly on Android devices. Generated from the shared Rust engine via UniFFI, it returns the standard ScanReport JSON string while your mobile app controls the camera, picker and UI.

It is published 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.

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

No. The SDK focuses strictly on on-device image decoding and leaves camera capture, runtime permissions, preview overlays and navigation to your app. Capture or compress an image to PNG, JPEG, WebP or GIF bytes from CameraX or the Android photo picker, then pass those bytes to scan().

scan() executes synchronously inside the native Rust library. Invoking it from Dispatchers.Default (or a background Executor in Java) keeps frame rendering and touch input responsive while the image is decoded.

It returns a valid ScanReport JSON with an empty detections array rather than throwing an exception. Confirm that trace.budget_exhausted is false before treating an empty result as final. Corrupt or unsupported inputs throw an exception, which your app should catch separately.

No. All decoding runs locally inside the native libraries packaged in your app, 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 are published under the MIT licence, permitting commercial and proprietary mobile apps 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.