Read saved QR images
Pass encoded PNG, JPEG, WebP or GIF bytes from Android’s photo picker, camera capture or device storage to scan() and get exact decoded text.
JitPack AAR
4 ABIs · 16 KB
On-device
MIT
Package the native Rust engine inside your APK or App Bundle while keeping complete control over camera UI, permissions and result actions.
Pass encoded PNG, JPEG, WebP or GIF bytes from Android’s photo picker, camera capture or device storage to scan() and get exact decoded text.
Run the synchronous native UniFFI call inside a Kotlin coroutine on Dispatchers.Default so scrolling, animations and camera previews remain smooth.
Read each detection’s symbology, content.text, structured payload and optional scannability score from the cross-platform ScanReport JSON string.
Configure the JitPack repository, depend on the Android AAR and decode image bytes off the main thread.
Add JitPack to your Gradle repositories, then add the single-line dependency for the Android AAR library on JitPack. Use the version string without a leading v prefix.
The AAR packages 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 from 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.
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 retains regular QR code detections (qr_code) and stays aware of raw fallbacks whenever content.charset is unknown.
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 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.
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 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 stale result.
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 Google Play Services.
Camera and JSON decoding. Your app controls CameraX/Camera2 capture and runtime permissions. Parse ScanReport leniently with Json { ignoreUnknownKeys = true }, and inspect content.charset / content.raw whenever 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.
Binding documentation, ScanReport schema and licensing references on GitHub.
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 phones and tablets. Generated from the shared Rust engine via UniFFI, it returns the standard ScanReport JSON string while your app controls the camera, picker and UI.
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.
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, 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 to PNG, JPEG, WebP or GIF bytes from CameraX or the Android 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 smooth while the image is decoded.
It returns a valid ScanReport JSON with an empty detections array instead of throwing an exception. Verify 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. All decoding executes locally inside the native libraries packaged into your app, 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 licence, allowing commercial and proprietary Play Store apps as long as you keep the copyright and licence notices (see LICENSING.md for third-party Apache-2.0 notices). SDK use is independent of QR Code AI’s paid creation plans and seven-day Premium trial.