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 575 forks source link

missing realm constructor - please ensure RealmReact framework is included #611

Closed ajithamp closed 7 years ago

ajithamp commented 8 years ago

i got above error

tugceakin commented 8 years ago

Same here on IOS. I linked the library by running "react-native link realm" and also checked if it is included in "Build Phases -> Link Binary With Libraries" in Xcode. But I still get the same error.

ajithamp commented 8 years ago

hi, if u r using Android

add following in MainApplication.java

import io.realm.react.RealmReactPackage;

protected List getPackages() { return Arrays.asList( new MainReactPackage(), new RealmReactPackage() // add this line ); }

add following two lines in settings.gradle include ':realm' project(':realm').projectDir = new File(settingsDir, '../node_modules/realm/android')

caoer commented 8 years ago

same error. using version

    "react": "15.3.2",
    "react-native": "0.35.0",
    "realm": "^0.14.3"
caoer commented 8 years ago

found what's wrong here.

Need to at least invoke any method for ReactRealm class to be loaded, so it can go through the module registration process.

add

#import <RealmReact/RealmReact.h>

and then in anywhere of your application. it doesn't need to be executed, just need to be there.

 NSLog(@"%@", [RealmReact class]);
alazier commented 8 years ago

@caoer very interesting! Sounds like symbols might be getting stripped. Will see if we can reproduce this by fiddling with the build settings.

brunobraga95 commented 7 years ago

@caoer could you explain again your solution with an example code? I did not quite understand. Thank you

caoer commented 7 years ago

@brunobraga95 just include RealmReact anywhere in the application; I guess there might be something related to lib load process. If you don't include <RealmReact/RealmReact.h> related lib won't get loaded.

brunobraga95 commented 7 years ago

Sorry to ask, I am new with native, but when you say to just include RealmReact, should I just

import Realm from 'realm'

Or there is another way to manually do it?

geldarhb commented 7 years ago

Hey all, We're getting this as a root cause for crashes reported by several users in our Production env. Mainly after CodePush downloads a new update for the app, and is about to restart the app.

Would really appreciate it if someone can shed some light on how can it happen in Production... :/

Thanks! Guy

stefanwuest commented 7 years ago

@geldarhb Hey, have you found out what the problem is?

kristiandupont commented 7 years ago

@stefanwuest are you still getting this? Which version of Realm are you using?

stefanwuest commented 7 years ago

I have crash reports on my production app. Can't reproduce it though. Using "realm": "^0.14.3"

kristiandupont commented 7 years ago

okay. Perhaps try upgrading. Or let me know if you get more information.

Kdoherty11 commented 7 years ago

@geldarhb @stefanwuest Any luck finding a solution for this? I'm seeing this too only in release and test flight builds.

jbcullis commented 7 years ago

I'm experiencing this too, was fine on RN 38 but since upgrading to 47 and now 48 we've been trying to trace this issue (iOS only). About to part ways with Realm. What's strange is, when the app appears to exit, if you double click home you'll see it sitting in the background.

bmunkholm commented 7 years ago

@Kdoherty11 @jbcullis We would love to help fix this, but we are unable to reproduce this ourselves, so anything that can help with that would be appreciated.

jbcullis commented 7 years ago

@Kdoherty11 Issue appeared after upgrading from RN 38.0 and Realm 1.2.0

Currently have tested on: RN 47.2 and 48.2 with realm 1.11.1, all dependencies have been upgraded to latest.

You can open the app a few times and it's fine and then randomly it will fail to load but this is only presenting itself in release on device. As someone mentioned in this thread or another it seems to get worse after a code-push.

My only dependencies are realm, codepush and now bugsnag. I can confirm it was broken before we added bugsnag and that's how we finally saw the error being thrown.

bmunkholm commented 7 years ago

Could you possibly provide us a sample app (in private) that shows this behavior?

jbcullis commented 7 years ago

@bmunkholm - I'm just testing a theory and then I'll put together a sample.

jbcullis commented 7 years ago

@bmunkholm - I can confirm that realm is the issue, libraries still in place but commented out the import and usage on launch page and no crashes.

bmunkholm commented 7 years ago

@jbcullis Great - it would be awesome with a repro sample!

jbcullis commented 7 years ago

@bmunkholm - Further information. There appeared to be two things going wrong, first was 'missing realm constructor' however it seems we've fixed that by moving first usage to login rather than at launch. Unfortunately, we still had that weird behavior where the app hangs just after the launch screen however it doesn't exit, it disappears but if you double click the home button the app is available in the background. We decided to try and lazy load the library at login, just before first usage which seems to have solved the issue.

In summary, I'm sure it's a timing issue so I'm going to try the solution outlined by @caoer to see if that yields the same result as lazy loading.

kneth commented 7 years ago

@jbcullis Did the outlines solution help you?

jbcullis commented 7 years ago

@kneth - No, the only way I was able to eliminate the problem was to load the library after the app had completed loading. So I left the const as null until the user logged in and then set the value at that point. For us, it feels hacky but there is no ramification since we don't set any offline data until the user logs in.

jbcullis commented 7 years ago

@bmunkholm - I haven't had a chance to get a sample together yet. Now that we have our production app bug free I hope to take a look at this later in the week.

kneth commented 7 years ago

@jbcullis We will look forward to a little sample project.

kneth commented 7 years ago

I am closing the issue. If you have a sample project, don't hesitate to reopen the issue.