4
votes

I cannot seem to get react-native-camera working in Expo. Here is a screenshot of the error I am receiving:

Camera error

The error originates on line 62 of react-native-camera index.js which is calling NativeModules.CameraManager. Does this have something to do with expo not having access to some native APIs?

Steps already taken:

  • react-native link react-native-camera
  • watchman watch-del-all
  • rm -rf node_modules && npm install
  • rm -fr $TMPDIR/react-*
  • npm start -- --reset-cache

Restarting the build

I also created a regular react native app via react-native init and was able to properly set up react-native-camera without any issues.

3
Is it an ejected projecet? If so, are you using react-native-navigation? I'm having this same problem, on Android.diogenesgg

3 Answers

3
votes

I reached out to the Expo team directly and this was the response I received:

custom native modules are not supported in expo unless you eject

see the sdk api reference section of docs to see what native apis we expose https://docs.expo.io/versions/v16.0.0/index.html

Answer from expo

1
votes

You have to use the expo camera from:

import { Camera, Permissions } from 'expo';

Take a look at:

https://docs.expo.io/versions/latest/sdk/camera.html
0
votes

As I understand, you want to use the camera with Expo. In this case you can use the Expo Camera package with comes with the Expo API

SDK API ReferenceCamera: https://docs.expo.io/versions/latest/sdk/camera.html

As background info - Expo and native modules: React-Native is able to use native app code and access native features, but it needs to be 'linked' via the native app code e.g. the POD file. In the case of Expo, the native app is already written and only executes your React Native code. With Expo, linking is only possible when you 'eject' or 'detach' from the original code, which does only make sense in some cases.