Android QR Code Scanner SDK

Run offline QR code scanning inside your Android mobile app. Add one MIT-licensed AAR from JitPack, decode image bytes off the main thread and receive URLs, text and QR quality diagnostics directly 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 get 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 now? 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

Run offline QR scanning in your Android app

Package the native Rust engine inside your APK or App Bundle while keeping full control over camera UI, permissions and result handling.

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 get exact decoded text.

Run off the main thread

Call the synchronous native UniFFI function inside a Kotlin coroutine on Dispatchers.Default so scrolling, animations and camera previews 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.

Set up QR image reading in Kotlin on Android

Configure 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 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 QR 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 so additive fields never break your parser. This example filters for standard 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 parameter picks 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/"]. Show the decoded string in your Android UI and let the user choose whether to copy it or open a browser intent.

An image containing no 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 carry the MIT licence (with Apache-2.0 notices in LICENSING.md) and are 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. Built from the shared Rust engine via UniFFI, it returns the standard ScanReport JSON string while your app manages the camera, picker and UI.

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

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

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

scan() runs synchronously inside the native Rust library. Calling it on Dispatchers.Default (or a background Executor in Java) keeps frame rendering and touch input responsive while the image decodes.

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

No. Decoding runs locally inside the native libraries bundled with your app, requiring no Google Play Services, 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.