realm / realm-js

Realm is a mobile database: an alternative to SQLite & key-value stores
https://realm.io
Apache License 2.0
5.79k stars 577 forks source link

React-Native app "keeps stopping" after installing realm and @realm/react in Application with navigation/drawer #4343

Closed reanzi closed 2 years ago

reanzi commented 2 years ago

How frequently does the bug occur?

All the time

Description

I expect to use drawer navigation in my app. I created the app as usual with npx , installed all library as per the docs (using navigation version-6 and react-native 0.66.4) everything worked so far, navigations, drawer, and conditional navigation. But after this: npm i realm @realm/react

the the application build with several warnings, but it does build,

`$ npm run android

uvuvi@0.0.1 android react-native run-android

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag. Jetifier found 1091 file(s) to forward-jetify. Using 8 workers...

info JS server already running. info Installing the app...

Task :realm:stripDebugDebugSymbols Unable to strip the following libraries, packaging them as they are: librealmreact.so.

Task :app:compileDebugJavaWithJavac

Task :app:stripDebugDebugSymbols Unable to strip the following libraries, packaging them as they are: librealmreact.so.

Task :app:installDebug Installing APK 'app-debug.apk' on 'tecno(AVD) - 9' for app:debug

Installed on 1 device.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 1m 32s 176 actionable tasks: 29 executed, 147 up-to-date info Connecting to the development server... info Starting the app on "emulator-5554"... Starting: Intent { cmp=com.uvuvi/.MainActivity }`

but the app fails to lunch and crashed every, no errors on the metro console, just emulator alert "uvuvi keeps stopping". when I run npm uninstall realm @realm/react the app build and lunch without a problem, also using npm i @realm/react alone works, meaning the app lunched but this won't work as this package depends on realm

Stacktrace & log output

When Running with only @realm/react installed, I get the following errors, which is okay because this package depends on realm

` ERROR  Error: Missing Realm constructor. Did you run "pod install"? Please see https://realm.io/docs/react-native/latest/#missing-realm-constructor for troubleshooting, js engine: hermes       
 ERROR  Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect. 
      This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes
 ERROR  Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect. 
      This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes`

Can you reproduce the bug?

Yes, always

Reproduction Steps

  1. create an react-native app npx react-native init Project

  2. initialize navigation, drawer navigation. as per documentations

  3. Install realm and @realm/react package npm i realm @realm/react

  4. Run the applciation `npm run android'

Version

realm: 10.13.0

What SDK flavour are you using?

MongoDB Realm (i.e. Sync, auth, functions)

Are you using encryption?

No, not using encryption

Platform OS and version(s)

windows 10, android Emulator

Build environment

Which debugger for React Native: .. react-native: 0.66.4

Cocoapods version

No response

reanzi commented 2 years ago

Just tested the same application with bottom-navigation, it lunch fine so my guess, react-native-gasture-handler and react-native-screens are messing things up; because those library are dependencies when using drawer-navigation but not bottom-navigation.

But I still want to using Drawer-Navigation, so I'll keep my ears on this if anyone can help

takameyer commented 2 years ago

Hi @reanzi , happy to hear you are trying out @realm/react and sorry to hear you are having issues in conjunction with react-navigation. I'll spin up an example app and see if I can reproduce this.

takameyer commented 2 years ago

@reanzi I do have a question. Are you using react-native-reanimated? We have had some conflicts with that library and Android in the past.

reanzi commented 2 years ago

@takameyer Yes I'm using react-native-reanimated

since I heard about MongoDb Realm, I knew my offline first applications have got a savior, because I don't like firebase that much though it have great resources. Using Realm seemed more natural to me. Hopefully this will be my go-to

takameyer commented 2 years ago

@reanzi We have a feature branch for Hermes support that fixes the compatibility issues we have with react-native-reanimated. It is quite stable by now, so I would recommend trying it out.

npm i realm@hermes

Just doing that might fix the issues you are having. Let us know if that works :)

reanzi commented 2 years ago

@takameyer , Thanks, I'll try and get back to you

reanzi commented 2 years ago

@reanzi We have a feature branch for Hermes support that fixes the compatibility issues we have with react-native-reanimated. It is quite stable by now, so I would recommend trying it out.

npm i realm@hermes

Just doing that might fix the issues you are having. Let us know if that works :)

Installed it and just as you said it worked, Thanks @takameyer this real pain in the bu** now I can proceed with the project :)

Just for the sake of feedback:

npm install realm@hermes

Just to be on the safe side, i did the following too at the root of my project

cd android && ./gradlew clean && cd .. && npm run android --reset-cache
takameyer commented 2 years ago

@reanzi Really happy that helped! Sorry for the inconvenience. Let us know if you have any other issues :)

mehraj43 commented 2 years ago

@reanzi Really happy that helped! Sorry for the inconvenience. Let us know if you have any other issues :)

im having the same issue i did install realm@hermes and the app still keeps on crashing plzz help me

mehraj43 commented 2 years ago

this is the error now it gives

ERROR Error: Exception in HostObject::get(propName:Realm): std::bad_alloc RouteStack@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.firstproj&modulesOnly=false&runModule=true:140778:82 RNCSafeAreaProvider SafeAreaProvider@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.firstproj&modulesOnly=false&runModule=true:161847:24 App@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.firstproj&modulesOnly=false&runModule=true:140710:26 Provider@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.firstproj&modulesOnly=false&runModule=true:141600:21 RNRDX RCTView View RCTView View AppContainer@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.firstproj&modulesOnly=false&runModule=true:79135:36 FirstProj(RootComponent)@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.firstproj&modulesOnly=false&runModule=true:85417:28 ERROR Error: Requiring module "src\navigation\stack\index.js", which threw an exception: Error: Exception in HostObject::get(propName:Realm): std::badalloc RouteStack@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.firstproj&modulesOnly=false&runModule=true:140778:82 RNCSafeAreaProvider SafeAreaProvider@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.firstproj&modulesOnly=false&runModule=true:161847:24 App@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.firstproj&modulesOnly=false&runModule=true:140710:26 Provider@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.firstproj&modulesOnly=false&runModule=true:141600:21 RNRDX RCTView View RCTView View AppContainer@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.firstproj&modulesOnly=false&runModule=true:79135:36 FirstProj(RootComponent)@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.firstproj&modulesOnly=false&runModule=true:85417:28 ERROR TypeError: undefined is not an object (evaluating '$$_REQUIRE(_dependencyMap[8], "./stack").AuthStack')

This error is located at: in RouteStack (at App.js:32) in RNCSafeAreaProvider (at SafeAreaContext.tsx:87) in SafeAreaProvider (at App.js:31) in App (at FirstProj/index.js:17) in Provider (at FirstProj/index.js:16) in RNRDX (at renderApplication.js:50) in RCTView (at View.js:32) in View (at AppContainer.js:92) in RCTView (at View.js:32) in View (at AppContainer.js:119) in AppContainer (at renderApplication.js:43) in FirstProj(RootComponent) (at renderApplication.js:60) ERROR TypeError: undefined is not an object (evaluating '_$$_REQUIRE(_dependencyMap[8], "./stack").AuthStack')

This error is located at: in RouteStack (at App.js:32) in RNCSafeAreaProvider (at SafeAreaContext.tsx:87) in SafeAreaProvider (at App.js:31) in App (at FirstProj/index.js:17) in Provider (at FirstProj/index.js:16) in RNRDX (at renderApplication.js:50) in RCTView (at View.js:32) in View (at AppContainer.js:92) in RCTView (at View.js:32) in View (at AppContainer.js:119) in AppContainer (at renderApplication.js:43) in FirstProj(RootComponent) (at renderApplication.js:60)

mehraj43 commented 2 years ago

Error: Exception in HostObject::get(propName:Realm): std::bad_alloc

takameyer commented 2 years ago

@mehraj43 Please create a new issue for this and provide the details of what environments you are using, versions of the packages you have installed and if possible a repo that replicates this issue.

mehraj43 commented 2 years ago

@mehraj43 Please create a new issue for this and provide the details of what environments you are using, versions of the packages you have installed and if possible a repo that replicates this issue.

thanks but i solved the issue i installed the package through yarn and deleted all node module and reinstall them and rebuilded and now its working but I can't understand why do i need to install an external package realm@hermes why haven't they resolved with reanimated v2

takameyer commented 2 years ago

why haven't they resolved with reanimated v2

We are focusing our efforts on realm@hermes which will become v11 of Realm. When this is released, we will be compatible with all other libraries.

mehraj43 commented 2 years ago

why haven't they resolved with reanimated v2

We are focusing our efforts on realm@hermes which will become v11 of Realm. When this is released, we will be compatible with all other libraries.

I'll be Waiting for the release. Thank you for your support.

reanzi commented 2 years ago

That's good news, thanks for your efforts guys. This package is really important.

Can't wait to dig into i, v11 :)

On Tue, 2 Aug 2022 at 12:07, Andrew Meyer @.***> wrote:

why haven't they resolved with reanimated v2

We are focusing our efforts on @.*** which will become v11 of Realm. When this is released, we will be compatible with all other libraries.

— Reply to this email directly, view it on GitHub https://github.com/realm/realm-js/issues/4343#issuecomment-1202220787, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE2EWN32TPLQ3UGJ7N4OEJ3VXDQMLANCNFSM5OK2SKUQ . You are receiving this because you were mentioned.Message ID: @.***>

jet2018 commented 2 years ago

Okay, I still have this issue, the app just crushes both on the emulator and phone. I have tried to implement all the above in this thread but nothing works!

kneth commented 2 years ago

@jet2018 Please create a new issue and fill in all fields in the issue template. If you can share code which can reproduce, it will be appreciated.

reanzi commented 2 years ago

What object are you trying passing in to get this error

'''

ERROR TypeError: undefined is not an object (evaluating '_$$_REQUIRE(_dependencyMap[8], "./stack").AuthStack') '''

Check your authStack On Tue, 2 Aug 2022 at 07:44, Mohammed Meraj @.***> wrote:

this is the error now it gives

ERROR Error: Exception in HostObject::get(propName:Realm): std::bad_alloc RouteStack@ http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.firstproj&modulesOnly=false&runModule=true:140778:82 RNCSafeAreaProvider SafeAreaProvider@ http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.firstproj&modulesOnly=false&runModule=true:161847:24 App@ http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.firstproj&modulesOnly=false&runModule=true:140710:26 Provider@ http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.firstproj&modulesOnly=false&runModule=true:141600:21 RNRDX RCTView View RCTView View AppContainer@ http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.firstproj&modulesOnly=false&runModule=true:79135:36 FirstProj(RootComponent)@ http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.firstproj&modulesOnly=false&runModule=true:85417:28 ERROR Error: Requiring module "src\navigation\stack\index.js", which threw an exception: Error: Exception in HostObject::get(propName:Realm): std::badalloc RouteStack@ http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.firstproj&modulesOnly=false&runModule=true:140778:82 RNCSafeAreaProvider SafeAreaProvider@ http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.firstproj&modulesOnly=false&runModule=true:161847:24 App@ http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.firstproj&modulesOnly=false&runModule=true:140710:26 Provider@ http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.firstproj&modulesOnly=false&runModule=true:141600:21 RNRDX RCTView View RCTView View AppContainer@ http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.firstproj&modulesOnly=false&runModule=true:79135:36 FirstProj(RootComponent)@ http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.firstproj&modulesOnly=false&runModule=true:85417:28 ERROR TypeError: undefined is not an object (evaluating '$$_REQUIRE(_dependencyMap[8], "./stack").AuthStack')

This error is located at: in RouteStack (at App.js:32) in RNCSafeAreaProvider (at SafeAreaContext.tsx:87) in SafeAreaProvider (at App.js:31) in App (at FirstProj/index.js:17) in Provider (at FirstProj/index.js:16) in RNRDX (at renderApplication.js:50) in RCTView (at View.js:32) in View (at AppContainer.js:92) in RCTView (at View.js:32) in View (at AppContainer.js:119) in AppContainer (at renderApplication.js:43) in FirstProj(RootComponent) (at renderApplication.js:60) ERROR TypeError: undefined is not an object (evaluating '_$$_REQUIRE(_dependencyMap[8], "./stack").AuthStack')

This error is located at: in RouteStack (at App.js:32) in RNCSafeAreaProvider (at SafeAreaContext.tsx:87) in SafeAreaProvider (at App.js:31) in App (at FirstProj/index.js:17) in Provider (at FirstProj/index.js:16) in RNRDX (at renderApplication.js:50) in RCTView (at View.js:32) in View (at AppContainer.js:92) in RCTView (at View.js:32) in View (at AppContainer.js:119) in AppContainer (at renderApplication.js:43) in FirstProj(RootComponent) (at renderApplication.js:60)

— Reply to this email directly, view it on GitHub https://github.com/realm/realm-js/issues/4343#issuecomment-1202011294, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE2EWN7ADINAVA6B4QT7QMDVXCRT7ANCNFSM5OK2SKUQ . You are receiving this because you were mentioned.Message ID: @.***>