Bundle a ReadOnly Realm in React Native (Android)

Hi there,

I’m trying to bundle a default realm to my React Native app. It is working perfectly on iOS by including it in ‘Copy Bundle Resources’.

However, the realm is not being copied to my android emulator when I put it inside /app/src/main/assets.

Therefore, I’m getting this error:

Screenshot 2020-07-24 at 13.52.03

I have tried following the instructions given here: https://stackoverflow.com/questions/42886434/bundle-pre-populated-realm-with-react-native-app

Any idea how I can get the realm to be bundled into the android app?

Any help greatly appreciated,

For anyone that finds this and is still stuck. Heres my solution:

Follow instructions here:

Ensure that you are calling Realm.copyBundledRealmFiles() before you initilize your realm.

I was originally init-ing realm in index.js But once I moved to something like this is worked fine:

let path;
if (Platform.OS === 'android') {
  path = 'realm.realm';
} else {
    path = fs.MainBundlePath + '/realm.realm';

export default new Realm({
  path: path,
  readOnly: true,
  schema: []});