简体   繁体   中英

Apk crashes after adding realm to react native

Thanks in advance.

I tried to install Realm 3.3.0 on react native and after generating the build when the app opens it crashes. I use

"react": "16.8.6",
"react-native": "0.60.5"

My gradle are

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 21
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.4.1")
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

I put up the log cat and i am getting the following;

beginning of crash
2019-10-24 18:07:16.929 11412-11498/com.xxxxx.xxxxx E/AndroidRuntime: FATAL EXCEPTION: create_react_context
Process: com.xxxx.xxxxx, PID: 11412
java.lang.UnsatisfiedLinkError: couldn't find DSO to load: librealmreact.so caused by: dlopen failed: library "libjsc.so" not found
at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:738)
at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:591)
at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:529)
at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:484)
at io.realm.react.RealmReactModule.<clinit>(RealmReactModule.java:56)
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:41)
at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1215)
at com.facebook.react.ReactInstanceManager.processPackages(ReactInstanceManager.java:1185)
at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1123)
at com.facebook.react.ReactInstanceManager.access$900(ReactInstanceManager.java:124)
at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:948)
at java.lang.Thread.run(Thread.java:764)

Is there any work around for this??

I use realm in my daily work, I have met this issue is because realm doesn't support hermes engine yet, see this issue , you need to change enableHermes to false in file android/app/build.gradle

project.ext.react = [
    entryFile: "index.js",
    enableHermes: false,
]

if you are using 0.60.0 or greater version the step to install realm is

  1. npm i realm

  2. npx react-native link realm , realm's autolink is not working yet, yes, you need link manually with command

  3. npx jetify

no need to edit MainAplication.java or other file to link more

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM