react-native-vision-camera: π Android unknown crash
device id of undefined
Camera.tsx
static getDerivedStateFromProps(props: CameraProps, state: CameraState): CameraState | null {
const newCameraId = props.device.id;
if (state.cameraId !== newCameraId) return { ...state, cameraId: newCameraId };
return null;
}
my code check
if(device && device.id) {
console.log(device.id)
}
crash app
android 10 xiaomi note 7
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 37 (14 by maintainers)
Hey! I ran into the same issue when testing out the module in my own application.
Only one of my devices actually printed any meaningful output when crashing. This was logged on a Samsung Galaxy S8+
The only difference I could see between the example app and my app, is that I use react-navigation instead of react-native-navigation
Looking into the react-native-navigation module I see that it has the following dependencies:
Also looking up the error message brought me here: https://stackoverflow.com/questions/52677638/module-with-main-dispatcher-is-missing which has some more information.
My current workaround for now is to add the following to my applications build.gradle
I havenβt dug much further or read too much into this, but maybe replacing
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2"
withimplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2"
in your modules build.gradle would solve the dependancy issue? This is just based on a quick look at the comments on the StackOverflow link, without actually going into details π
I removed my workaround and did a fresh install. I can confirm that the issue is gone my part at least!
@vinkim thank you for the details!! Helps a lot. Iβve just published 1.0.1 on npm with coroutines-android instead of core, let me know if that works for you guys.
Awesome. I wasnβt sure if kotlinx-coroutines-core was included in the kotlinx-coroutines-android package, but if it works for you I assume it is. π
Thanks again for your awesome research, took me about 20 seconds to see whatβs going on π