Realm: create causing a crash within android (react-native)

1.8k Views Asked by At

The example below is working fine while in debug is enabled using React Native Debugger but the app is crashing in normal mode for Android only. Can someone assist me resolve this issue, please?

  const Cat = {
    name: "Cat",
    properties: {
      _id: "string",
      name: "string",
      age: "int",
      type: "string",
    },
  };



    const db = await Realm.open({
    schema: [Cat],
    schemaVersion: 1,
    });
    
      const cats = db.objects("Cat");
      console.log(`There are ${cats.length} cats`);
    
      db.write(() => {
    
         db.create("Cat", {  // this step is causing the crash
          _id: '1',
          name: "Alice",
          age: 14,
          type: "Calico",
        });
      });

"react": "17.0.2", "react-native": "0.66.4", "realm": "^10.13.0","react-native-reanimated": "^2.2.0",

Stacktrace

Type Time PID Tag Message 11:08:52.623 32560 libc Fatal signal 7 (SIGBUS), code 1 (BUS_ADRALN), fault addr 0xfffffffb in tid 1370 (mqt_js), pid 32560 (com.myfarmapp)

11:08:52.872    1434    DEBUG   pid: 32560, tid: 1370, name: mqt_js  >>> com.myfarmapp <<<

11:08:52.878    1434    DEBUG         #00 pc 002e3aa4  /data/app/com.myfarmapp-rtw-Mt49iUsbq8iCz8dIdw==/lib/arm/libjsc.so!libjsc.so (offset 0x75000) (BuildId: 184cbb2602409d8d87c82858f210bcb5255b9e8c)

11:08:52.878    1434    DEBUG         #01 pc 002e118f  /data/app/com.myfarmapp-rtw-Mt49iUsbq8iCz8dIdw==/lib/arm/libjsc.so!libjsc.so (offset 0x75000) (BuildId: 184cbb2602409d8d87c82858f210bcb5255b9e8c)

11:08:52.878    1434    DEBUG         #02 pc 002e0ec5  /data/app/com.myfarmapp-rtw-Mt49iUsbq8iCz8dIdw==/lib/arm/libjsc.so!libjsc.so (offset 0x75000) (BuildId: 184cbb2602409d8d87c82858f210bcb5255b9e8c)

11:08:52.878    1434    DEBUG         #03 pc 000718bd  /data/app/com.myfarmapp-rtw-Mt49iUsbq8iCz8dIdw==/lib/arm/libjsc.so (BuildId: 184cbb2602409d8d87c82858f210bcb5255b9e8c)

11:08:52.879    1434    DEBUG         #04 pc 000715e9  /data/app/com.myfarmapp-rtw-Mt49iUsbq8iCz8dIdw==/lib/arm/libjsc.so (BuildId: 184cbb2602409d8d87c82858f210bcb5255b9e8c)

11:08:52.879    1434    DEBUG         #05 pc 002891bf  /data/app/com.myfarmapp-rtw-Mt49iUsbq8iCz8dIdw==/lib/arm/libjsc.so!libjsc.so (offset 0x75000) (BuildId: 184cbb2602409d8d87c82858f210bcb5255b9e8c)

11:08:52.879    1434    DEBUG         #06 pc 00288d9d  /data/app/com.myfarmapp-rtw-Mt49iUsbq8iCz8dIdw==/lib/arm/libjsc.so!libjsc.so (offset 0x75000) (BuildId: 184cbb2602409d8d87c82858f210bcb5255b9e8c)

11:08:52.879    1434    DEBUG         #07 pc 002892f1  /data/app/com.myfarmapp-rtw-Mt49iUsbq8iCz8dIdw==/lib/arm/libjsc.so!libjsc.so (offset 0x75000) (BuildId: 184cbb2602409d8d87c82858f210bcb5255b9e8c)

11:08:52.879    1434    DEBUG         #08 pc 0027d381  /data/app/com.myfarmapp-rtw-Mt49iUsbq8iCz8dIdw==/lib/arm/libjsc.so!libjsc.so (offset 0x75000) (BuildId: 184cbb2602409d8d87c82858f210bcb5255b9e8c)

11:08:52.879    1434    DEBUG         #09 pc 002b2955  /data/app/com.myfarmapp-rtw-Mt49iUsbq8iCz8dIdw==/lib/arm/libjsc.so!libjsc.so (offset 0x75000) (BuildId: 184cbb2602409d8d87c82858f210bcb5255b9e8c)

11:08:52.879    1434    DEBUG         #10 pc 00169a39  /data/app/com.myfarmapp-rtw-Mt49iUsbq8iCz8dIdw==/lib/arm/libjsc.so!libjsc.so (offset 0x75000) (BuildId: 184cbb2602409d8d87c82858f210bcb5255b9e8c)

11:08:54.151    4062    ActivityManager crash : com.myfarmapp,0
11:08:54.158    4062    ActivityTaskManager   Force finishing activity com.myfarmapp/.MainActivity
11:08:54.336    4062    InputDispatcher channel '3f863f2 com.myfarmapp/com.myfarmapp.MainActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9, fd=520
11:08:54.336    4062    InputDispatcher channel '3f863f2 com.myfarmapp/com.myfarmapp.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
11:08:54.342    4062    WindowManager   WIN DEATH: Window{3f863f2 u0 com.myfarmapp/com.myfarmapp.MainActivity}
2

There are 2 best solutions below

0
On BEST ANSWER

The issue has been resolved after upgrading the realm to v10.20.0-beta.2

https://github.com/realm/realm-js/issues/4399#issuecomment-1061722341

0
On

npm install [email protected]

import realm use this

const Realm = require('realm');