反应原生MainApplication.java方法不会覆盖或实现超类型的方法

时间:2018-10-30 14:33:40

标签: android react-native react-native-maps

今天您好,我在项目中安装了react-native-maps,并对其进行了配置,但是当我运行react-native run-android时,它向我显示错误:

> Task :app:compileDebugJavaWithJavac FAILED
/home/valentino/Scrivania/test/android/app/src/main/java/com/test/MainApplication.java:38: error: method does not override or implement a method from a supertype
  @Override
  ^
1 error

this is the link of the guide I followed on github to configure react-native-maps.

在MainApplication.java中,我添加了import com.airbnb.android.react.maps.MapsPackage

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

public class MainApplication extends Application implements ReactApplication {中。

你知道我能克服这个问题吗?

更新

TheWanderer解决了先前的问题后,终端向我显示以下错误:

> Task :app:compileDebugJavaWithJavac FAILED
/home/valentino/Scrivania/test/android/app/src/main/java/com/test/MainApplication.java:38: error: method getPackages() is already defined in class <anonymous com.test.MainApplication$1>
    protected List<ReactPackage> getPackages() {
                                 ^
1 error

谢谢

1 个答案:

答案 0 :(得分:1)

看看sample

该方法是ReactNativeHost的一部分。您可以在那里看到如何实现。