HMS-Core / hms-react-native-plugin

This repo contains all of React-Native HMS plugins.
https://developer.huawei.com/consumer/en/doc/overview/HMS-Core-Plugin?ha_source=hms1
Apache License 2.0
247 stars 68 forks source link

Error: Native module HMSMapViewModule tried to override Module #126

Closed ramisalem closed 3 years ago

ramisalem commented 3 years ago

Hello, I am getting the following error on "@hmscore/react-native-hms-map": "^5.2.0-302"

IMAGE 2021-06-16 09:41:31

// MainApplication.java 

import com.huawei.hms.rn.map.HMSMapPackage;

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 that cannot be autolinked yet can be added manually here, for example:
          // packages.add(new MyReactNativePackage());
           packages.add(new HMSMapPackage());
          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);
    initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
  }
ramisalem commented 3 years ago

@aktug @Mike-mei Any help here!

ozcanozgur commented 3 years ago

Hi @ramisalem,

If you add the plugin via npm, please don't add the package manually. For React Native 0.60+ its linking automatically. That's the reason you are getting the "module is being created twice" error.

Thank you.

ramisalem commented 3 years ago

@ozcanozgur Thanks for the answer