expo: [expo-barcode-scanner][11.1.2][BarcodeScanner] Scans only once and won't scan again
Summary
If I use permissions: [CAMERA, … etc] under android: in app.json and list all permissions for my app, the expo-barcode-scanner will only scan once and not scan again. If i remove the permissions tag to allow expo to include all permissions, it works as expected. the reason i need to explicitly list permissions is the play store rejected my app b/c of the location data permissions. i don’t use location data in my app so i thought i’d use permissions to say which ones to use.
"permissions": ["CAMERA", "ACCESS_MEDIA_LOCATION", "ACCESS_WIFI_STATE", "ACCESS_NETWORK_STATE", "INTERNET", "SYSTEM_ALERT_WINDOW", "WAKE_LOCK", "MANAGE_DOCUMENTS", "READ_INTERNAL_STORAGE", "READ_PHONE_STATE", "USE_FINGERPRINT", "VIBRATE", "MODIFY_AUDIO_SETTINGS", "READ_CONTACTS", "READ_CALENDAR", "WRITE_CALENDAR", "READ_EXTERNAL_STORAGE", "RECORD_AUDIO", "WRITE_EXTERNAL_STORAGE", "WRITE_SETTINGS", "RECEIVE_BOOT_COMPLETED", "USE_BIOMETRIC", "FOREGROUND_SERVICE", "READ_APP_BADGE", "com.odfl.odflloadmgmt.permission.C2D_MESSAGE", "host.exp.exponent.permission.C2D_MESSAGE", "com.anddoes.launcher.permission.UPDATE_COUNT", "com.android.launcher.permission.INSTALL_SHORTCUT", "com.google.android.c2dm.permission.RECEIVE", "com.google.android.gms.permission.ACTIVITY_RECOGNITION", "com.google.android.providers.gsf.permission.READ_GSERVICES", "com.htc.launcher.permission.READ_SETTINGS", "com.htc.launcher.permission.UPDATE_SHORTCUT", "com.majeur.launcher.permission.UPDATE_BADGE", "com.sec.android.provider.badge.permission.READ", "com.sec.android.provider.badge.permission.WRITE", "com.sonyericsson.home.permission.BROADCAST_BADGE", "com.sonymobile.home.permission.PROVIDER_INSERT_BADGE", "com.anddoes.launcher.permission.UPDATE_COUNT", "com.majeur.launcher.permission.UPDATE_BADGE", "com.huawei.android.launcher.permission.CHANGE_BADGE", "com.huawei.android.launcher.permission.READ_SETTINGS", "com.huawei.android.launcher.permission.WRITE_SETTINGS", "com.oppo.launcher.permission.READ_SETTINGS", "com.oppo.launcher.permission.WRITE_SETTINGS", "me.everything.badger.permission.BADGE_COUNT_READ", "me.everything.badger.permission.BADGE_COUNT_WRITE", "com.google.android.providers.gsf.permission.READ_GSERVICES", "com.google.android.gms.permission.ACTIVITY_RECOGNITION", "com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE" ]
What am I missing?
I’m upgrade from Expo 39 to Expo 43. This same code works in Expo 39 and barcode-scanner v9.
Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!
managed
What platform(s) does this occur on?
Android
SDK Version (managed workflow only)
43.0.1
Environment
Expo CLI 4.12.10 environment info: System: OS: macOS 11.6 Shell: 5.8 - /bin/zsh Binaries: Node: 16.12.0 - ~/.nvm/versions/node/v16.12.0/bin/node Yarn: 1.22.15 - ~/.yarn/bin/yarn npm: 8.1.0 - ~/.nvm/versions/node/v16.12.0/bin/npm Watchman: 2021.10.18.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.8.4 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 15.0, DriverKit 20.4, macOS 11.3, tvOS 15.0, watchOS 8.0 Android SDK: Android NDK: 22.1.7171670 IDEs: Android Studio: 2020.3 AI-203.7717.56.2031.7784292 Xcode: 13.0/13A233 - /usr/bin/xcodebuild npmPackages: expo: ^43.0.1 => 43.0.1 react: 17.0.1 => 17.0.1 react-dom: 17.0.1 => 17.0.1 react-native: 0.64.2 => 0.64.2 react-native-web: 0.17.1 => 0.17.1 react-navigation: ^4.4.2 => 4.4.4 npmGlobalPackages: expo-cli: 4.12.10 Expo Workflow: managed
Reproducible demo or steps to reproduce from a blank project
Happy Path:
- create a new project with 2 pages.
- page 1 displays the scanned data
- page 2 has the barcodescanner component. on a successful scan, navigate back to page 1 (close page 2)
- verify page 1 receives scanned data and you can keep going to page 2 to scan additional barcodes
Sad Path:
5) kill the app/expo server.
6) in app.json, add the permissions tag under android
"permissions": ["CAMERA", "ACCESS_MEDIA_LOCATION", "ACCESS_WIFI_STATE", "ACCESS_NETWORK_STATE", "INTERNET", "SYSTEM_ALERT_WINDOW", "WAKE_LOCK", "MANAGE_DOCUMENTS", "READ_INTERNAL_STORAGE", "READ_PHONE_STATE", "USE_FINGERPRINT", "VIBRATE", "MODIFY_AUDIO_SETTINGS", "READ_CONTACTS", "READ_CALENDAR", "WRITE_CALENDAR", "READ_EXTERNAL_STORAGE", "RECORD_AUDIO", "WRITE_EXTERNAL_STORAGE", "WRITE_SETTINGS", "RECEIVE_BOOT_COMPLETED", "USE_BIOMETRIC", "FOREGROUND_SERVICE", "READ_APP_BADGE", "com.odfl.odflloadmgmt.permission.C2D_MESSAGE", "host.exp.exponent.permission.C2D_MESSAGE", "com.anddoes.launcher.permission.UPDATE_COUNT", "com.android.launcher.permission.INSTALL_SHORTCUT", "com.google.android.c2dm.permission.RECEIVE", "com.google.android.gms.permission.ACTIVITY_RECOGNITION", "com.google.android.providers.gsf.permission.READ_GSERVICES", "com.htc.launcher.permission.READ_SETTINGS", "com.htc.launcher.permission.UPDATE_SHORTCUT", "com.majeur.launcher.permission.UPDATE_BADGE", "com.sec.android.provider.badge.permission.READ", "com.sec.android.provider.badge.permission.WRITE", "com.sonyericsson.home.permission.BROADCAST_BADGE", "com.sonymobile.home.permission.PROVIDER_INSERT_BADGE", "com.anddoes.launcher.permission.UPDATE_COUNT", "com.majeur.launcher.permission.UPDATE_BADGE", "com.huawei.android.launcher.permission.CHANGE_BADGE", "com.huawei.android.launcher.permission.READ_SETTINGS", "com.huawei.android.launcher.permission.WRITE_SETTINGS", "com.oppo.launcher.permission.READ_SETTINGS", "com.oppo.launcher.permission.WRITE_SETTINGS", "me.everything.badger.permission.BADGE_COUNT_READ", "me.everything.badger.permission.BADGE_COUNT_WRITE", "com.google.android.providers.gsf.permission.READ_GSERVICES", "com.google.android.gms.permission.ACTIVITY_RECOGNITION", "com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE" ]
7) rerun the app and the barcodescanner will scan successfully the first time. after that, scans no longer work.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 7
- Comments: 29 (4 by maintainers)
I had the same issue. Switching from
expo-barcode-scannertoexpo-cameraworks. I can scan as many times as I want without issue using Expo 43.I can confirm it. Scan only once.
I had to go back to Expo 42 with expo-barcode-scanner 10.2.2. This appears to be the last working version of Expo and the barcode scanner. I’m stuck on Expo 42 until this is fixed.
Same issue here on iOS and Android, after upgrading to 43, the
<Camera />component wont scan any barcodes. Problem is, we really need the flash toggle, so moving to expo-barcode-scanner is out of question … shouldn’t have updated to 43 …Yes its happening to me too. Hi, @cruzach any updates?
I’m getting this issue on Android only… It scan only first time…
Also something is wrong with Camera Access on Android… In my case, a webivew screen that has camera access also fails to access camera once the barcode scanning is used.
It seems like camera on Barcode Scanner is not unmounting properly.
A workaround for this by using React.useMemo to trigger re-render.
@kineticV that’s so weird, I have the same issue, but with expo-camera … as we have a few scooter rental apps, and they rely solely on the app being able to actually scan that QR code … for some it just crashes, for others, it just doesn’t scan.
I can also confirm it.