[Bug]: Android 17: scanner closes with OS-PLUG-BARC-0004 because CameraX 1.5.1 throws on unknown dynamic range profile 8192
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- Mezza giornata
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- android
- Ambito
- mobile
Direzione di ricerca
Start with the CameraX version declared in android/build.gradle and the OSBARCScannerActivity error path that maps the failure to OS-PLUG-BARC-0004. Check whether ionbarcode-android pins its own CameraX version, since the fix may need to land there too. Reproduce on an Android 17 emulator with the back camera, then confirm the scanner stays open after bumping CameraX to 1.6.x and that Android 16 still works.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Current Behavior
On Android 17 (API 37), scanBarcode() opens the scanner activity, which closes again after about 1 second, and the promise rejects with:
{"message":"Error while trying to scan code.","code":"OS-PLUG-BARC-0004"}
Logcat at that moment:
E OSBARCScannerActivity: Dynamic range profile cannot be converted to a DynamicRange object: 8192
The back camera on Android 17 advertises dynamic range profiles that CameraX 1.5.1 doesn't know (8192 and 16384 in android.request.availableDynamicRangeProfilesMap). In CameraX 1.5.1, DynamicRangesCompatApi33Impl.profileToDynamicRange() wraps the conversion in Preconditions.checkNotNull(...). An unknown profile therefore throws while the camera is being bound, and ionbarcode-android reports that as the generic SCANNING_GENERAL_ERROR (0004).
Starting with CameraX 1.6, the same conversion (DynamicRangeProfilesCompatApi33Impl.profileToDynamicRange()) only logs a warning and skips the unknown profile. I checked the sources of 1.5.1, 1.6.2 and 1.7.0-rc01.
Expected Behavior
The scanner opens and stays open on Android 17, as it does on Android 16.
Reproduction
- Use any app with
@capacitor/barcode-scanner3.1.3 (which pulls CameraX 1.5.1) and callCapacitorBarcodeScanner.scanBarcode({ hint: CapacitorBarcodeScannerTypeHint.ALL }). - Run it on the Android Emulator with the Android 17 (API 37.1) Google Play system image and
-camera-back emulated. - The scanner closes immediately and the call rejects with
OS-PLUG-BARC-0004. The same APK works on an API 36 emulator.
adb shell dumpsys media.camera shows the back camera advertising profile 8192. The front camera doesn't, which is why it only fails with the back camera.
Environment Details
@capacitor/barcode-scanner3.1.3 (3.1.4-dev-20261007T140411.0still declares CameraX 1.5.1)io.ionic.libs:ionbarcode-android2.1.1androidx.camera:*1.5.1, resolved through the plugin@capacitor/core/@capacitor/android8.6- compileSdk / targetSdk 36, AGP 8.13
Versions Affected
3.1.3, and the current 3.1.4 dev build
Platforms Affected
- iOS
- Android
- Web
Notes / Comments
Workaround that fixed it for us: force CameraX 1.6.2 from the app module (android/app/build.gradle):
dependencies {
constraints {
['camera-core', 'camera-camera2', 'camera-lifecycle', 'camera-view'].each { module ->
implementation("androidx.camera:${module}:1.6.2") {
because 'CameraX 1.5 throws on dynamic range profiles added in Android 17'
}
}
}
}
With that change, the release build (R8 enabled) opens the scanner on Android 17, and logcat shows the message only as a warning (W CXCP: Dynamic range profile cannot be converted to a DynamicRange object: 8192 / 16384). Android 16 keeps working. CameraX 1.6.2 requires compileSdk 36 and AGP 8.9.1 or newer.
Suggested fix: bump the CameraX dependencies in android/build.gradle (and in ionbarcode-android, if it pins them) to 1.6.x.
So far we've only seen this on the emulator. Real Android 17 devices may advertise different profiles, but any camera that advertises a profile newer than CameraX 1.5.1 will hit the same exception.
#141 looks related: CameraX rejects a value it doesn't recognize (lens facing 255 there), and the user also only sees the generic OS-PLUG-BARC-0004. It might help to forward the underlying exception message in the rejection, so these cases can be diagnosed without logcat.
- Lingua principale
- TypeScript
- Stelle
- 65
- Fork
- 47
- Merge medio
- 2g 15h
- PR unite (30g)
- 6
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ionic-team/capacitor-barcode-scanner
-
Difficoltà 4/5 1-2 giorni Idoneità per principianti 30/100
-
[Bug]: Android: CameraX initialization fails when device reports unsupported LENS_FACING value 255Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 38/100
ionic-team/capacitor-barcode-scanner#133 · 2 reazioni ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 45/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
ionic-team/capacitor-barcode-scanner#94 · 1 reazione ·
Tutte le issue di ionic-team/capacitor-barcode-scanner
Issue simili
-
status/need-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
google-gemini/gemini-cli#30328 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[hooks] SessionStart injects the knowledge-update frontmatter on a CRLF checkoutForse già presa @abhiramshaji-cyber l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
vercel/vercel-plugin#429 ·
I maintainer di solito rispondono entro 1 giorno
-
severity:medium triage:confirmed triage:in-progress triage:reproduced
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
Cotal-AI/Cotal#7231 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
boxlite-ai/boxlite#2777 ·
I maintainer di solito rispondono entro 1 giorno