运行react-native run-android时,在MainActivity.java上出错

时间:2016-09-01 17:54:54

标签: java android react-native

我正在运行react-native run-android,我在编译时遇到此错误。

  

:app:compileDebugJavaWithJavac - 不是增量的(例如输出已更改,之前没有执行等)

     

MainActivity.java:37:error:方法不会覆盖或实现超类型的方法       @覆盖       ^   1错误   :app:compileDebugJavaWithJavac FAILED

     

失败:构建因异常而失败。

我真的不知道怎么办,所以任何建议都非常受欢迎。

我已安装:

  • javac 1.8.0_101
  • react-native-cli:1.0.0
  • react-native:0.32.0

修改

这是MainActivity.java

public class MainActivity extends ReactActivity {

    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "netbeast";
    }

    /**
     * Returns whether dev mode should be enabled.
     * This enables e.g. the dev menu.
     */
    @Override
    protected boolean getUseDeveloperSupport() {
        return BuildConfig.DEBUG;
    }

    /**
     * A list of packages used by the app. If the app uses additional views
     * or modules besides the default ones, add more packages here.
     */
    @Override  **//This is the line 37 where the error occurs**
    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
            new VectorIconsPackage(),
            new UdpSocketsModule(),
            new RNNetworkInfoPackage()
        );
    }
}

1 个答案:

答案 0 :(得分:0)

尝试运行react-native upgrade,这将更新mainActivity.java。