realm / realm-js

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

app crashes after build #4444

Closed oguzhannkayaa closed 2 years ago

oguzhannkayaa commented 2 years ago

How frequently does the bug occur?

All the time

Description

After I installed realm in my react-native app, app crashes without error.

"react-native": "^0.67.4", "realm": "^10.14.0", gradle version 7.2 node version :15.2.0

Stacktrace & log output

No response

Can you reproduce the bug?

Yes, always

Reproduction Steps

npm install realm after that npx react-native android-run

Version

^10.14.0

What SDK flavour are you using?

Local Database only

Are you using encryption?

No, not using encryption

Platform OS and version(s)

android

Build environment

Which debugger for React Native: ..

Cocoapods version

No response

kneth commented 2 years ago

@oguzhan10 If you downgrade to 10.13.0, does it work?

oguzhannkayaa commented 2 years ago

trying now @kneth

oguzhannkayaa commented 2 years ago

no app still crash but in android studio termibnal I foudn this error


2022-03-24 16:48:28.080 10111-10186/com.test E/SoLoader: couldn't find DSO to load: librealm.so caused by: couldn't find DSO to load: libjsc.so
        SoSource 0: com.facebook.soloader.ApkSoSource[root = /data/data/com.test/lib-main flags = 1]
        SoSource 1: com.facebook.soloader.DirectorySoSource[root = /data/app/~~zCgPqfWO4cWjVhvcqaoWbw==/com.test-j8_XgxNzt5FFHCussJTEHQ==/lib/x86_64 flags = 0]
        SoSource 2: com.facebook.soloader.DirectorySoSource[root = /vendor/lib64 flags = 2]
        SoSource 3: com.facebook.soloader.DirectorySoSource[root = /system/lib64 flags = 2]
        Native lib dir: /data/app/~~zCgPqfWO4cWjVhvcqaoWbw==/com.test-j8_XgxNzt5FFHCussJTEHQ==/lib/x86_64
     result: 0 result: 0
2022-03-24 16:48:28.082 10111-10186/com.test E/AndroidRuntime: FATAL EXCEPTION: create_react_context
    Process: com.test, PID: 10111
    java.lang.UnsatisfiedLinkError: couldn't find DSO to load: librealm.so caused by: couldn't find DSO to load: libjsc.so
        SoSource 0: com.facebook.soloader.ApkSoSource[root = /data/data/com.test/lib-main flags = 1]
        SoSource 1: com.facebook.soloader.DirectorySoSource[root = /data/app/~~zCgPqfWO4cWjVhvcqaoWbw==/com.test-j8_XgxNzt5FFHCussJTEHQ==/lib/x86_64 flags = 0]
        SoSource 2: com.facebook.soloader.DirectorySoSource[root = /vendor/lib64 flags = 2]
        SoSource 3: com.facebook.soloader.DirectorySoSource[root = /system/lib64 flags = 2]
        Native lib dir: /data/app/~~zCgPqfWO4cWjVhvcqaoWbw==/com.test-j8_XgxNzt5FFHCussJTEHQ==/lib/x86_64
     result: 0 result: 0
        at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:918)
        at com.facebook.soloader.SoLoader.loadLibraryBySoNameImpl(SoLoader.java:740)
        at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:654)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:634)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:582)
        at io.realm.react.RealmReactModule.<clinit>(RealmReactModule.java:57)
        at io.realm.react.RealmReactPackage.createNativeModules(RealmReactPackage.java:31)
        at com.facebook.react.ReactPackageHelper.getNativeModuleIterator(ReactPackageHelper.java:42)
        at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:42)
        at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1462)
        at com.facebook.react.ReactInstanceManager.processPackages(ReactInstanceManager.java:1433)
        at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1327)
        at com.facebook.react.ReactInstanceManager.access$1200(ReactInstanceManager.java:138)
        at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:1104)
        at java.lang.Thread.run(Thread.java:920)
     Caused by: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libjsc.so
        SoSource 0: com.facebook.soloader.ApkSoSource[root = /data/data/com.test/lib-main flags = 1]
        SoSource 1: com.facebook.soloader.DirectorySoSource[root = /data/app/~~zCgPqfWO4cWjVhvcqaoWbw==/com.test-j8_XgxNzt5FFHCussJTEHQ==/lib/x86_64 flags = 0]
        SoSource 2: com.facebook.soloader.DirectorySoSource[root = /vendor/lib64 flags = 2]
        SoSource 3: com.facebook.soloader.DirectorySoSource[root = /system/lib64 flags = 2]
        Native lib dir: /data/app/~~zCgPqfWO4cWjVhvcqaoWbw==/com.test-j8_XgxNzt5FFHCussJTEHQ==/lib/x86_64
     result: 0
        at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:918)
        at com.facebook.soloader.SoLoader.loadLibraryBySoNameImpl(SoLoader.java:740)
        at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:640)
        at com.facebook.soloader.DirectorySoSource.loadDependencies(DirectorySoSource.java:121)
        at com.facebook.soloader.DirectorySoSource.loadLibraryFrom(DirectorySoSource.java:71)
        at com.facebook.soloader.UnpackingSoSource.loadLibrary(UnpackingSoSource.java:477)
        at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:860)
            ... 14 more

``` @kneth
kneth commented 2 years ago

Are you using JavaScriptCore or Hermes as JS engine? If you are using Hermes, you need to use v10.20.0-beta.2.

oguzhannkayaa commented 2 years ago

How can I check it ? @kneth I didnt add extra package.I am using JavaScriptcore.


  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@notifee/react-native": "^5.0.0",
    "@react-native-community/datetimepicker": "^6.1.0",
    "@react-navigation/native": "^6.0.8",
    "@react-navigation/stack": "^6.1.1",
    "moment": "^2.29.1",
    "native-base": "^3.3.7",
    "react": "17.0.2",
    "react-native": "^0.67.4",
    "react-native-bottomsheet-reanimated": "^0.2.0",
    "react-native-gesture-handler": "^2.3.2",
    "react-native-image-crop-picker": "^0.37.3",
    "react-native-material-dropdown-v2": "^0.11.1",
    "react-native-paper": "^4.11.2",
    "react-native-pure-chart": "0.0.24",
    "react-native-reanimated": "^2.3.0",
    "react-native-safe-area-context": "^4.2.2",
    "react-native-screens": "^3.13.1",
    "react-native-svg": "^12.3.0",
    "react-native-uuid": "^2.0.1",
    "react-native-vector-icons": "^9.1.0",
    "realm": "^10.12.0",
    "reanimated-bottom-sheet": "^1.0.0-alpha.22"
  },
  "devDependencies": {
    "@babel/core": "^7.17.8",
    "@babel/runtime": "^7.17.8",
    "@react-native-community/eslint-config": "^3.0.1",
    "babel-jest": "^27.5.1",
    "eslint": "^8.11.0",
    "jest": "^27.5.1",
    "metro-react-native-babel-preset": "^0.69.1",
    "react-test-renderer": "17.0.2"
  },
  "jest": {
    "preset": "react-native"
  }```
kneth commented 2 years ago

The issue is react-native-reanimated. If you want to use that library, you will have to use Hermes as engine - and use Realm JS v10.20.0-beta.2 or later. See also https://github.com/realm/realm-js/issues/3940

oguzhannkayaa commented 2 years ago

Project is finally working but I am getting a weird error. When I render the page. When there is no data it shows page but when there is gives below error. @kneth Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

tomduncalf commented 2 years ago

Hey @oguzhan10, that usually indicates an error somewhere in your React Native code, for example I've had it in the past when I've mixed up default and named exports. I don't think it's likely to be a Realm thing. Unfortunately it's not always obvious where the error is from from the stack trace so fixing it can require some trial and error...

I would suggest trying to strip your app down to just the bare minimum (e.g. just rendering "Hello world" from your App component and see if that works), then add in your other components/code one by one until you find what is triggering the problem.