在将React Native与现有Android应用程序集成时需要未知模块“Rea
我正在尝试集成最新的React Native构建,并且我遇到了错误.这是我的项目设置:
在app的build.gradle中,我导入react-native 0.24.1: dependencies { ... compile 'com.facebook.react:react-native:0.24.1' } 项目的build.gradle指向Git子模块中的React Native: allprojects { repositories { jcenter() maven { // All of React Native (JS,Obj-C sources,Android binaries) is installed from npm url "$projectDir/../MyGitSubmodule/AwesomeProject/node_modules/react-native/android" } } } 我已按照文档here中的描述进行了集成,并按照文档here中的描述在git子模块中升级了RN.我已将我的堆栈跟踪上传到此pastebin link.要总结堆栈跟踪,因为格式化很难阅读,这些是亮点: >无法为类com.facebook.react.views.text.ReactVirtualTextViewManager找到生成的setter – 这适用于大量的Native类.也许所有这些. 解决方法
基本上,它抱怨模块ReactPerf是必需的,但它不存在.
仅供参考,ReactPerf模块:https://www.npmjs.com/package/react-addons-perf. 从逻辑上讲,我们只需要告诉react-native来安装这个东西. 棘手的部分是,如果我们这样做: npm install react-addons-perf,然后我们将它安装在react-native依赖项的“外部”.因此,它会抱怨react-addons-perf也需要反应包. 解决方案是我们需要声明这个依赖“inside”react-native包.换一种说法: 打开node_modules / react-native / package.json.你会找到 ... "dependencies": { "absolute-path": "^0.0.0","art": "^0.10.0","babel-core": "~6.4.5","babel-plugin-external-helpers": "~6.4.0",... "react": "^0.14.5" ... } 所以,我们需要做的就是为这些添加react-addons-perf. ... "dependencies": { "absolute-path": "^0.0.0",... "react": "^0.14.5","react-addons-perf": "^0.14.5",// ADD THIS LINE FOR ReactPerf module ... } 然后,npm安装. 根据我的经验,其余的错误,如需要模块“8”也将消失. 它对我有用,希望它也适合你. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |