2

According to the latest documentation for MongoDB Realm React Native, it states that their SDK is compatible with Expo...

Expo now supports Realm with the Expo SDK version 44. To use Realm with Expo, upgrade to Expo SDK version 44. Realm does not work with earlier versions of Expo.

We have installed Expo and have the latest version of their SDK, however no matter what we try we get an error stating "Missing Ream Constructor":

enter image description here

We require the project to be in the Expo managed workflow and not the bare workflow. When we setup in bare workflow, it works.

Are we missing something??

Matt Price
  • 1,371
  • 2
  • 9
  • 19
  • Did you look at the [Getting Started Template](https://github.com/expo/examples/tree/master/with-realm) and follow the [Setup Guide](https://reactnative.dev/docs/environment-setup)? There's even handle blog post [Build an Offline-First React Native Mobile App with Expo and Realm](https://medium.com/realm/build-an-offline-first-react-native-mobile-app-with-expo-and-realm-e904cc883a51) – Jay Feb 08 '22 at 18:03
  • The blog link Jay posted led me to this [expo template](https://github.com/realm/realm-js/tree/master/templates/expo-template-js) in the realm repo. That's worth looking at for some things not mentioned in the documentation, namely the index.js contents. However, even cloning and running that template gives me the constructor error, so I opened [this issue](https://github.com/realm/realm-js/issues/4332) on github – ChiefMcFrank Feb 10 '22 at 22:47
  • 1
    Just an update: a contributor replied to the issue I opened and said Realm does not have Expo Go app support. I don't know if you're using that, but he left some info on building a client on your test device. – ChiefMcFrank Feb 11 '22 at 08:57

3 Answers3

0

Some of the settings I made to fix:

REMEMBER: react-native-reanimated doesn't work with Realm & Expo

Following the documentation

  • Rather than run with expo start or npx react-native [platform] run yarn android for iOS or yarn ios
  • Install Java SDK version 8
  • Uninstall react-native: npm uninstall -g react-native and run npx react-native run-android

If you got this error:

A problem occurred configuring project ':realm'.

Could not create task ':realm:compileDebugJavaWithJavac'. Could not create task ':realm:forwardDebugPort'. > SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at 'C:\Users\yourUser\Desktop\Projects\MyAwesomeRealmApp\android\local.properties'. `

To fix this:

  • Create a file with the name local.properties in android directory
  • Open the file and paste your Android SDK path like below: sdk.dir=C:\\Users\\UserName\\AppData\\Local\\Android\\sdk
0

Experienced this issue using @realm/react: 0.4.3, realm: 11.8.0

Check your script for building for android in package.json.

In my case it was expo start --android, and changing it to expo run:android fixed the problem (must build app for Realm to work).

This is the command included in the official template for expo-realm found in npm. https://www.npmjs.com/package/@realm/expo-template?activeTab=code

  "scripts": {
    "start": "expo start --dev-client",
    "android": "expo run:android",
    ....

*haven't checked ios

Mike Mat
  • 632
  • 7
  • 15
0

Run using expo run:ios or expo run:android

Hora
  • 162
  • 1
  • 8