React-native-firebase: RN 0.60 Android error: native module RNFirebase tried to override RNFirebaseModule

Created on 27 Jul 2019  路  9Comments  路  Source: invertase/react-native-firebase

New rn version crash with react-native-firebase on Android

Versions

    "react": "16.8.6",
    "react-native": "0.60.4",
    "react-native-firebase": "^5.5.5",

MainApplication.java with new getPackages() function

    @Override
    protected List<ReactPackage> getPackages() {
      @SuppressWarnings("UnnecessaryLocalVariable")
      List<ReactPackage> packages = new PackageList(this).getPackages();
      // Packages that cannot be autolinked yet can be added manually here, for example:
      // packages.add(new MyReactNativePackage());
      packages.add(new RNFirebasePackage());
      packages.add(new RNFirebaseDatabasePackage());
      packages.add(new RNFirebaseAuthPackage());
      return packages;
    }

Error:
Screenshot_2019-07-27-14-51-49-694_com smok_app

Most helpful comment

protected List<ReactPackage> getPackages() {
      @SuppressWarnings("UnnecessaryLocalVariable")
      List<ReactPackage> packages = new PackageList(this).getPackages();
      // Packages that cannot be autolinked yet can be added manually here, for example:
      // packages.add(new MyReactNativePackage());
      packages.add(new RNFirebasePackage()); //=> remove this line and also from header import
      packages.add(new RNFirebaseDatabasePackage());
      packages.add(new RNFirebaseAuthPackage());
      return packages;
}

All 9 comments

Overlap with 0.60 autolink. Remove from MainApplication.java like it says. But eventually you will likely hit the redbox I'm getting: https://github.com/invertase/react-native-firebase/issues/2411

protected List<ReactPackage> getPackages() {
      @SuppressWarnings("UnnecessaryLocalVariable")
      List<ReactPackage> packages = new PackageList(this).getPackages();
      // Packages that cannot be autolinked yet can be added manually here, for example:
      // packages.add(new MyReactNativePackage());
      packages.add(new RNFirebasePackage()); //=> remove this line and also from header import
      packages.add(new RNFirebaseDatabasePackage());
      packages.add(new RNFirebaseAuthPackage());
      return packages;
}

This is unrelated to react-native-firebase, I have a demo that shows how to successfully build and run RN60 - you can see how it does what it does, or just use it for boilerplate https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh

Can the documentation be updated to reflect this? It still shows the old way where the package is included and the old way of including module packages as well.

@TrekSoft it certainly can be! There's an edit button at the top of each documentation page, please make a PR 馃檹

Ok awesome - let me verify my code works and I'll do that.

Here it is for auth and if this looks good, will submit another one for all the other modules: https://github.com/invertase/react-native-firebase-docs/pull/208

protected List<ReactPackage> getPackages() {
      @SuppressWarnings("UnnecessaryLocalVariable")
      List<ReactPackage> packages = new PackageList(this).getPackages();
      // Packages that cannot be autolinked yet can be added manually here, for example:
      // packages.add(new MyReactNativePackage());
      packages.add(new RNFirebasePackage()); //=> remove this line and also from header import
      packages.add(new RNFirebaseDatabasePackage());
      packages.add(new RNFirebaseAuthPackage());
      return packages;
}

thanks god for born you

Thank-you!

Was this page helpful?
0 / 5 - 0 ratings