Android: chooseFromGallery crashes with EACCES permission denied on Android Scoped Storage (huawei)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- android, kotlin
- Ambito
- mobile-dev
Direzione di ricerca
Inizia da IONCAMRMediaProcessor.kt:81 e segui il risultato della galleria attraverso IONCAMRGalleryManager.kt:126 e :240, come identificato nello stack trace. Verifica come viene aperta l’immagine selezionata e conferma con la riproduzione su Huawei EMUI 12 che chooseFromGallery restituisce l’immagine senza un crash EACCES.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Current Behavior
@capacitor/camera: 8.2.1
Camera.getPhoto() works correctly.
Camera.chooseFromGallery() crashes on Android Huawei devices. (IOS and web ok)
Environment:
- EMUI : 12.0.0
- Huawei P30 Pro
- modèle VOG-L29
Code:
Camera.chooseFromGallery({
quality: 80,
targetWidth: 600,
targetHeight: 600,
includeMetadata: false, (tried true)
})
Crash:
java.io.FileNotFoundException:
/storage/emulated/0/Pictures/IMG_20260119_112248.jpg:
open failed: EACCES (Permission denied)
Stacktrace:
IONCAMRMediaProcessor.createImageMediaResult
ExifInterface.
The plugin seems to access the absolute filesystem path instead of using ContentResolver/content:// URI.
FATAL EXCEPTION: DefaultDispatcher-worker-1
Process: com.xx.xxxx, PID: 32117
java.io.FileNotFoundException: /storage/emulated/0/Pictures/Screenshots/Screenshot_20260708_121645_com.huawei.android.launcher.jpg: open failed: EACCES (Permission denied)
at libcore.io.IoBridge.open(IoBridge.java:496)
at java.io.FileInputStream.(FileInputStream.java:159)
at java.io.FileInputStream.(FileInputStream.java:115)
at android.media.ExifInterface.initForFilename(ExifInterface.java:2363)
at android.media.ExifInterface.(ExifInterface.java:1415)
at io.ionic.libs.ioncameralib.processor.IONCAMRMediaProcessor.createImageMediaResult(IONCAMRMediaProcessor.kt:81)
at io.ionic.libs.ioncameralib.processor.IONCAMRMediaProcessor.createImageMediaResult$default(IONCAMRMediaProcessor.kt:65)
at io.ionic.libs.ioncameralib.manager.IONCAMRGalleryManager.createMediaResult(IONCAMRGalleryManager.kt:240)
at io.ionic.libs.ioncameralib.manager.IONCAMRGalleryManager.onChooseFromGalleryResult(IONCAMRGalleryManager.kt:126)
at com.capacitorjs.plugins.camera.IonCameraFlow$processResultFromGallery$1.invokeSuspend(IonCameraFlow.kt:901)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:811)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:715)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:702)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@1efbba4, Dispatchers.Default]
Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
at libcore.io.Linux.open(Native Method)
at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252)
at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:8464)
at libcore.io.IoBridge.open(IoBridge.java:482)
... 15 more
-------------------- (with the addition of service tag on manifest.xml ):
FATAL EXCEPTION: DefaultDispatcher-worker-2
Process: com.xxx.xxxxx, PID: 3638
java.io.FileNotFoundException: /storage/emulated/0/Pictures/Screenshots/Screenshot_20260708_121645_com.huawei.android.launcher.jpg: open failed: EACCES (Permission denied)
at libcore.io.IoBridge.open(IoBridge.java:496)
at java.io.FileInputStream.(FileInputStream.java:159)
at java.io.FileInputStream.(FileInputStream.java:115)
at android.media.ExifInterface.initForFilename(ExifInterface.java:2363)
at android.media.ExifInterface.(ExifInterface.java:1415)
at io.ionic.libs.ioncameralib.processor.IONCAMRMediaProcessor.createImageMediaResult(IONCAMRMediaProcessor.kt:81)
at io.ionic.libs.ioncameralib.processor.IONCAMRMediaProcessor.createImageMediaResult$default(IONCAMRMediaProcessor.kt:65)
at io.ionic.libs.ioncameralib.manager.IONCAMRGalleryManager.createMediaResult(IONCAMRGalleryManager.kt:240)
at io.ionic.libs.ioncameralib.manager.IONCAMRGalleryManager.onChooseFromGalleryResult(IONCAMRGalleryManager.kt:126)
at com.capacitorjs.plugins.camera.IonCameraFlow$processResultFromGallery$1.invokeSuspend(IonCameraFlow.kt:901)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:811)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:715)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:702)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@2d03a37, Dispatchers.Default]
Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
at libcore.io.Linux.open(Native Method)
at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252)
at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:8464)
at libcore.io.IoBridge.open(IoBridge.java:482)
... 15 more
Expected Behavior
When selecting an image from the gallery with Camera.chooseFromGallery(), the plugin should successfully return the selected image without crashing.
The plugin should handle Android Scoped Storage correctly by using the content URI provided by Android (ContentResolver/content:// URI) instead of trying to access the image through an absolute filesystem path.
Reproduction
- Install the app on an Android Huawei device with EMUI 12.
- Use @capacitor/camera version 8.2.1.
- Call: Camera.chooseFromGallery({ quality: 80, targetWidth: 600, targetHeight: 600, includeMetadata: false });
- Select an existing image from the gallery.
- The application crashes. The issue does not happen with: - Camera.getPhoto({ source: CameraSource.Photos }) -
iOS and Web : ok
Screenshots / Media
No response
Environment Details
Latest Dependencies:
@capacitor/cli: 8.4.2
@capacitor/core: 8.4.2
@capacitor/android: 8.4.2
@capacitor/ios: 8.4.2
Installed Dependencies:
@capacitor/cli: 8.4.1
@capacitor/core: 8.4.1
@capacitor/android: 8.4.1
@capacitor/ios: 8.4.1
@capacitor/camera": "^8.2.1"
node 22
minSdkVersion = 24
compileSdkVersion = 36
targetSdkVersion = 36
androidxActivityVersion = '1.11.0'
androidxAppCompatVersion = '1.7.1'
androidxCoordinatorLayoutVersion = '1.3.0'
androidxCoreVersion = '1.17.0'
androidxFragmentVersion = '1.8.9'
coreSplashScreenVersion = '1.2.0'
androidxWebkitVersion = '1.14.0'
junitVersion = '4.13.2'
androidxJunitVersion = '1.3.0'
androidxEspressoCoreVersion = '3.7.0'
cordovaAndroidVersion = '14.0.1'
Versions Affected
8.2.1
Platforms Affected
- iOS
- Android
- Web
Notes / Comments
I suspect the issue is related to Huawei EMUI Scoped Storage handling.
The selected image seems to be returned as a filesystem path:
/storage/emulated/0/Pictures/...
instead of being processed through a content URI.
Android's MediaStore/Photo Picker should probably be accessed through ContentResolver to avoid permission issues.
- Lingua principale
- TypeScript
- Stelle
- 6
- Fork
- 3
- Merge medio
- 2g 18h
- PR unite (30g)
- 6
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
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-camera
-
bug(android): NullPointerException on ActivityResultLauncher.unregister() in LegacyCameraFlowAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
ionic-team/capacitor-camera#75 · 1 reazione ·
-
[Bug]: Crash SecurityException: No persistable permission grants found in IONCAMROpenPhotoPickerActivityForse già presa @ankit-edii l’ha presa 24 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
ionic-team/capacitor-camera#58 · 1 commento ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 67/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
ionic-team/capacitor-camera#76 · 1 commento · 1 reazione ·
Tutte le issue di ionic-team/capacitor-camera
Issue simili
-
twilio.webhook() rejects valid requests when the query string has an encoded `?` and a `+` spaceAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
twilio/twilio-node#1232 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
I maintainer di solito rispondono entro 1 giorno
-
Tiling managers are not destroyed in disable(), so window-created handlers keep running (Gio.Settings constructed without schema)Forse già presa @gnacho l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
domferr/tilingshell#641 ·
I maintainer di solito rispondono entro 3 giorni
-
🐛 bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
LibreChat-AI/LibreChat#17887 ·
I maintainer di solito rispondono entro 1 giorno
-
`isCI` is `true` inside a running Google Cloud Run service (also Railway, Render, Deno Deploy)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100