【react-native-picker】报错解决方案
时间:2018-12-13 10:30:01 关键字: native react 解决方案 手机看文章 [导读]在安装react-native-picker过程中,react-native link报错,且没有任何错误日志说明错误原因,导致运行项目时出现undefined is not an object (e在安装react-native-picker过程中,react-native link报错,且没有任何错误日志说明错误原因,导致运行项目时出现undefined is not an object (evaluating 'Picker._init')的错误。
网上找到了两个解决方案:
https://github.com/beefe/react-native-picker/issues/289
https://github.com/beefe/react-native-picker/issues/294
综合整理后,解决方案如下:
1.文件./android/settings.gradle中末尾添加:
include ':react-native-picker' project(':react-native-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-picker/android')
2.文件./android/app/build.gradle的dependencies内添加(注意其他行有逗号",",最后一行没逗号):
... dependencies { ... compile project(':react-native-picker') } ...
3.文件./android/app/src/main/java/com/xxx/xxx/MainApplication.java中添加:
import com.beefe.picker.PickerViewPackage; ... @Override protected ListgetPackages() { return Arrays.asList( new MainReactPackage(), ... new PickerViewPackage() ); } ...
4.重新运行项目就OK了。
标签:picker,...,解决方案,react,报错,native From: https://www.cnblogs.com/sexintercourse/p/16974183.html