react-native-device-info: method does not override or implement a method from a supertype @Override

i have updated react-native version from 0.44.0 to 0.48.1, after which i am unable to make a build. it is giving this error

myapp\node_modules\react-native-device-info\android\src\main\java\com\learnium\RNDeviceInfo\RNDeviceInfo.java:26: error: method does not override or implement a method from a supertype
  @Override                                                          
  ^
1 error                                                              
:react-native-device-info:compileReleaseJavaWithJavac FAILED         

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-device-info:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 36

Commits related to this issue

Most upvoted comments

It is a known issue easy fixed.

It is due to a RN breaking change so just remove @Override in RNDeviceInfo.java

What is wrong:

public class RNDeviceInfo implements ReactPackage {

  @Override
  public List<NativeModule> createNativeModules(
                              ReactApplicationContext reactContext) {
    List<NativeModule> modules = new ArrayList<>();

    modules.add(new RNDeviceModule(reactContext));

    return modules;
  }

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

  @Override
  public List<ViewManager> createViewManagers(
                            ReactApplicationContext reactContext) {
  	return Collections.emptyList();
  }

}

replace with:

public class RNDeviceInfo implements ReactPackage {


  public List<NativeModule> createNativeModules(
                              ReactApplicationContext reactContext) {
    List<NativeModule> modules = new ArrayList<>();

    modules.add(new RNDeviceModule(reactContext));

    return modules;
  }


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


  public List<ViewManager> createViewManagers(
                            ReactApplicationContext reactContext) {
  	return Collections.emptyList();
  }

}

try yarn upgrade react-native-device-info It solved the issue for me

Same for me, updated to RN 0.47.2

@angeloocana I’m gonna to open an issue on react-native page

Same error for RN 0.48.4 with react-native-device-info@0.10.2

I think the problem is that npm is pulling 0.10.2, but for RN 0.47+ we need 0.11+. The docs mention this, but maybe react-native-device-info should by default point to 0.11.0 instead. To fix it, I ran react-native unlink react-native-device-info && npm uninstall react-native-device-info, followed by npm install --save react-native-device-info@0.11.0 and finally react-native link react-native-device-info.

now I got this error for the first time… yesterday was ok… I’m using react-native 0.44

The solution in this issue solves the problem: https://github.com/facebook/react-native/issues/19259

@angeloocana for me isn’t just this library… but also other 5 libraries… I don’t know what happened…