React Native Android: Method does not override or implement a method from a supertype

﹥>﹥吖頭↗ 提交于 2019-12-23 06:56:51

问题


I've added react-native-fbsdk to my react native project and have it building fine on iOS. But on the android side, I can't get gradle to build the project. When trying to compile react-native-fbsdk, I'm hitting: "method does not override or implement a method from a supertype"

21:41:11.863 [INFO] [org.gradle.api.internal.tasks.compile.JdkJavaCompiler] Compiling with JDK Java compiler API.
21:41:12.100 [ERROR] [system.err] /Users/joncursi/Sites/joncursi/redbirdNative/node_modules/react-native-fbsdk/android/src/main/java/com/facebook/reactnative/androidsdk/FBSDKPackage.java:61: error: method does not override or implement a method from a supertype

Which points to the following code snippet within react-native-fbsdk:

@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
    return Collections.emptyList();
}

When I delete @Override, this particular instance of the error goes away, but I hit the same error in another module such as react-native-image-picker:

:react-native-image-picker:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
/Users/joncursi/Sites/joncursi/redbirdNative/node_modules/react-native-image-picker/android/src/main/java/com/imagepicker/ImagePickerPackage.java:34: error: method does not override or implement a method from a supertype
  @Override
  ^
1 error

I suspect this to be an issue with my local setup. Any ideas on what could be wrong here?


回答1:


The error is very vague (and imo a bit of a mess up in the react native release flow).

React-native 0.47.0 had a breaking change that meant libs had to patch their code.

Remove unused createJSModules calls (ce6fb33, 53d5504) - source

My guess is that you just have to update the libraries for which this error shows up, and otherwise submit a PR.

Here's an example of a lib fixing it: https://github.com/rebeccahughes/react-native-device-info/pull/191/files

Update:

The PR you're waiting for is here: https://github.com/facebook/react-native-fbsdk/pull/354



来源:https://stackoverflow.com/questions/45580452/react-native-android-method-does-not-override-or-implement-a-method-from-a-supe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!