four-eyes
four-eyes

Reputation: 12385

Undefined is not an object _expo.camera.constant when using expo Camera SDK

I created a RN project with create-react-native-app (CRNA). I want to use the Camera API provided by expo. In doing so, I simply copied the example here https://docs.expo.io/versions/latest/sdk/camera.html and included the Component. Starting the App gives me the following: Undefined is not an object _expo.camera.constant with a massive stacktrace... Any ideas what is going wrong here?

Upvotes: 0

Views: 2157

Answers (2)

Aniket Yadav
Aniket Yadav

Reputation: 139

For those that are having problems with the camera set up. Just change: import {Camera, Permissions} ... by these lines:

import * as Permissions from 'expo-permissions';
import { Camera } from 'expo-camera';

You will need to install the camera so you need to install using this command:

expo install expo-camera

Now just run your app and Cheers!

Upvotes: 3

Gaëtan DUAHMEL
Gaëtan DUAHMEL

Reputation: 31

I ran into the same issue trying to use Expo Camera API into a CRNA project. I manage to access the Camera API with an Expo SDK upgrade. Here are the steps I followed:

  1. In app.json change my Expo SDK version : "sdkVersion": "20.0.0",
  2. In package.jsonchange my current dependencies for Expo, React and React Native:

"expo": "20.0.0-alpha.4", "react": "16.0.0-alpha.12", "react-native":"https://github.com/expo/react-native/archive/sdk-20.0.0.tar.gz",

  1. Delete my node_modulesfolder
  2. Run npm install again

These steps didn't break the packager: I still can launch my project with npm start and from Expo XDE. Though, I didn't take time to test side effects, particularly for the eject process provided by CRNA.

I could only advice to test this fix on a not-for-production app.

Nonetheless, hope this could help!

Upvotes: 1

Related Questions