gpt4 book ai didi

javascript - React-Native 方法不会覆盖或实现父类(super class)型的方法

转载 作者:行者123 更新时间:2023-12-01 02:46:06 30 4
gpt4 key购买 nike

我在 Android 上遇到此错误

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

在文件

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

IOS端工作得很好。我安装了 React-Native-Maps 之后它似乎开始失败,但我不确定。我使用 Yarn 和 rnpm 来链接包。 React-Native 链接

现在文件看起来像这样:

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;
}
}

我尝试删除node_modules并重新安装、更新包甚至使用react。但问题似乎仍然存在。我正在使用节点 6.11.4

我的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"
]
}
}
}
}

最佳答案

我认为你的问题是你在 createJSModules() 上有一个 @Override 注释。该方法不在 ReactPackage 接口(interface)中。尝试删除该方法。

编辑:我相信该方法已在 0.47 中从界面中删除。

关于javascript - React-Native 方法不会覆盖或实现父类(super class)型的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47251479/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com