user11119814
user11119814

Reputation:

RNFirebase tried to override RNFirebaseModule - in case there isn't any duplications

I'm getting the following error:

enter image description here

In case that there isn't any duplicated packages or imports in MainApplication.java.

Here is my MainApplication.java:

package com.myfirebaseapp;

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

import com.facebook.react.PackageList;
import com.facebook.hermes.reactexecutor.HermesExecutorFactory;
import com.facebook.react.bridge.JavaScriptExecutorFactory;
import com.facebook.react.ReactApplication;
import io.invertase.firebase.RNFirebasePackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;


import io.invertase.firebase.messaging.RNFirebaseMessagingPackage;
import io.invertase.firebase.notifications.RNFirebaseNotificationsPackage;



import java.util.List;

public class MainApplication extends Application implements ReactApplication {

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

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

    @Override
    protected String getJSMainModuleName() {
      return "index";
    }
  };

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

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
  }
}

I took a look in other Questions but all said that there must have some duplicated packages or imports but I don't have any. If there is someone that had this error before or can tell me how to fix it?

Another error I get when I put "new MainReactPackage()" (as I know it must be there, but it is not) is -"... can't find/read simbol -MainReactPackage...".

Please Help :D

Upvotes: 1

Views: 4496

Answers (2)

Zeeshan Ansari
Zeeshan Ansari

Reputation: 10868

Remove the below lines

import io.invertase.firebase.RNFirebasePackage;
import io.invertase.firebase.messaging.RNFirebaseMessagingPackage;
import io.invertase.firebase.notifications.RNFirebaseNotificationsPackage;

packages.add(new RNFirebasePackage());
packages.add(new RNFirebaseMessagingPackage());
packages.add(new RNFirebaseNotificationsPackage());

Then react-native run-android

Upvotes: 1

Piyushh
Piyushh

Reputation: 613

remove packages.add(new RNFirebasePackage()); from your MainApplication.java In React-native > 0.59 the packages link automatically and so you don't need this package to be added.

Upvotes: 3

Related Questions