Realm-js: Missing Realm constructor....

Created on 27 May 2016  路  14Comments  路  Source: realm/realm-js

android Missing Realm constructor - please ensure RealmReact framework is included

Most helpful comment

see here
I tried this and it worked for me.
Add this import in MainApplication.java
import io.realm.react.RealmReactPackage;
also modify getPackages() to

@Override
protected List getPackages() {

  return Arrays.<ReactPackage>asList(

      new MainReactPackage(), new RealmReactPackage ()// this line

  );

}

All 14 comments

my rnpm version is 1.7.0

Can you confirm that you ran rnpm link realm, and that it modified your gradle files along with your MainActivity.java file?

@appden rnpm link realm is ok,but How to modify the gradle files ,my issue for react native

When you run rnpm link realm, it should modify your build.gradle and settings.gradle files along with MainActivity.java. Did they get updated for you? If not, please ensure you have the latest version of Realm (0.13.2) a try running rnpm link realm again. If that still does not work, will you be willing to let me take a look at your project?

I'm getting same error message with Android.
rnpm version 1.9.0
realm 0.14.2

How can I fix this?

(btw: does work with iOS)

@beebase what version of react-native are you running? Did you by chance update your project from an older version? There were some upgrade steps required when updating between some previous RN versions.

I am getting same error message with android.
rnpm version 1.9.0
realm 0.14.3
react-native 0.31.0
What can be done to solve this ?

see here
I tried this and it worked for me.
Add this import in MainApplication.java
import io.realm.react.RealmReactPackage;
also modify getPackages() to

@Override
protected List getPackages() {

  return Arrays.<ReactPackage>asList(

      new MainReactPackage(), new RealmReactPackage ()// this line

  );

}

@oajaskm Thank you, for your time and help. It works.

I'm usign same versions like @SatanPandeya, and I make the changes @oajaskm suggests, but same error: Missing realm constructor...

/android/settings.graddle
rootProject.name = 'VaspenApp'

include ':app'
include ':realm'
project(':realm').projectDir = new File(rootProject.projectDir, '../node_modules/realm/android')
/android/app/src/main/java/com/vaspenapp/MainApplication.java
package com.vaspenapp;

import android.app.Application;
import android.util.Log;

import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import io.realm.react.RealmReactPackage;

import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    protected boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new RealmReactPackage()
      );
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
      return mReactNativeHost;
  }
}

@leo7r If you make the changes like that, I am not sure but if you re-install the app and start the package manager may solve your issue.

@SatanPandeya everything is fine now, thank you!

@leo7r I also have the same problem Miss realm constructor even if I make the changes like that.Could you tell me how did you solve that?

I modify MyApplication.java build.gradle and setting.gradle ,but also cannot work, warn me Missing Realm constructor

Was this page helpful?
0 / 5 - 0 ratings

Related issues

blagoev picture blagoev  路  3Comments

MihaelIsaev picture MihaelIsaev  路  3Comments

jmartindivmedianet picture jmartindivmedianet  路  3Comments

fever324 picture fever324  路  4Comments

texas697 picture texas697  路  3Comments