简体   繁体   中英

React-Native method does not override or implement a method from a supertype

I am getting this error on android

 Error:(15, 5) error: method does not override or implement a method from a supertype;

At file

.../node_modules/react-native-package-manager/android/src/main/java/com/rnlib/packagemanager/RNPackageManager.java

IOS side works just fine. I installed React-Native-Maps after which it seemed to start failing, but I'm not sure. I'm using Yarn and rnpm to link the packages. React-Native link

Right now the file looks like this:

package com.rnlib.packagemanager;

import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class RNPackageManager implements ReactPackage {

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

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

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

        modules.add(new Module(reactContext));

        return modules;
    }
}

I've tried removing node_modules and reinstalling, updating packages and even react. Still the problem seems to persist. I'm using Node 6.11.4

My package.json

{
  "name": "wayfarer",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "start": "react-native start",
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "test": "jest",
    "lint": "eslint . --fix",
    "clean_cache": "npm start -- --reset-cache",
    "clean": "rm -rf $TMPDIR/react-* && watchman watch-del-all && npm cache clean"
  },
  "jest": {
    "preset": "react-native"
  },
  "dependencies": {
    "global": "^4.3.2",
    "haversine": "^1.1.0",
    "immutable": "^3.8.2",
    "lodash": "^4.17.4",
    "prop-types": "^15.6.0",
    "react": "16.1.0",
    "react-native": "^0.50.3",
    "react-native-gesture-responder": "^0.1.1",
    "react-native-maps": "^0.17.1",
    "react-native-package-manager": "^0.0.1",
    "react-native-vector-icons": "^4.4.2",
    "react-navigation": "^1.0.0-beta.19",
    "react-redux": "^5.0.6",
    "redux": "^3.7.2",
    "redux-thunk": "^2.2.0",
    "remote-redux-devtools": "^0.5.12",
    "vectors": "^0.1.0"
  },
  "devDependencies": {
    "babel-eslint": "^8.0.1",
    "babel-jest": "^21.2.0",
    "babel-preset-react-native-stage-0": "^1.0.1",
    "eslint": "^4.9.0",
    "eslint-config-airbnb-base": "^12.1.0",
    "eslint-plugin-import": "^2.8.0",
    "eslint-plugin-jsx-a11y": "^6.0.2",
    "eslint-plugin-react": "^7.4.0",
    "eslint-plugin-react-native": "^3.1.0",
    "jest": "^21.2.1",
    "react-test-renderer": "^16.0.0",
    "remotedev-rn-debugger": "^0.8.3"
  },
  "settings": {
    "import/resolver": {
      "node": {
        "extensions": [
          ".js",
          ".android.js",
          ".ios.js"
        ]
      }
    }
  }
}

I think your problem is you have an @Override annotation on createJSModules(). That method is not in the ReactPackage interface. Try removing the method.

Edit: I believe that method was removed from the interface in 0.47.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM