【转】ReactNative开发之疑难杂症
1.Unrecognized font family ‘Material Icons’
1).Then run
react-native start --reset-cache
2).Finally run
react-native run-ios
to restart the simulator2.出现如下黄色提示
1 |
Remote debugger is in a background tab which may cause apps to perform slowly. Fix this by foregrounding the tab (or opening it in a separate window).
|
把chrome的Tab页保持最前,窗口不要最小化
参考链接
3.ios真机运行xcode报错
1 |
Signing for “YiChunTests” requires a development team. Select a development team in the project editor.
|
别忘记修改test下的Team
4.android真机运行
白屏,检查手机设置以及安全软件设置,打开悬浮窗选项
参考链接
5.
1 |
Warning: PropTypes has been moved to a separate package. Accessing React.PropTypes is no longer supported and will be removed completely in React 16. Use the prop-types package on npm instead.
|
1 |
import React, {PropTypes } from ‘react’;
|
修改为
1 |
import PropTypes from ‘prop-types’;
|
参考链接
6.
1 |
ExceptionsManager.js:73 Warning: React.createClass is no longer supported. Use a plain JavaScript class instead. If you’re not yet ready to migrate, create-react-class is available on npm as a drop-in replacement.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
// 15.4 以前
var React = require(‘react’);
var Component = React.createClass({
mixins: [MixinA],
render() {
return <Child />;
}
});
// 15.5 以后
var React = require(‘react’);
var createReactClass = require(‘create-react-class’);
var Component = createReactClass({
mixins: [MixinA],
render() {
return <Child />;
}
});
|
参考链接
7.使用react-native-image-crop-picker报错
1
2
3
|
dyld: Library not loaded: .framework/QBImagePicker
Referenced from: /var/containers/Bundle/Application/A9C4A1F8-6299-493E-B56C-E1A629561451/CropPicker.app/CropPicker
Reason: image not found
|
在Target下点击General,选择Embedded Binaries单击+并添加RSKImageCropper.framework和QBImagePicker.framework
参考链接
8.使用react-navigation的TabNavigator,某个子界面设置tabBarVisible: false,切回时会报错
1 |
Cannot read property ‘setNativeProps’ of undefined
|
react-navigation/mode_models/react-native-tab-view中src/TabViewPagerPan.js的componentDidUpdate
将
1 |
this._transitionTo(this.props.navigationState.index)
|
改为
1 |
setTimeout(this._transitionTo, 0, this.props.navigationState.index);
|
github
9.androis studio debug时出现提示,如果下载不成功需要开v*n下载
1 |
c++ debugger package is missing or incompatible
|
相关链接
10.react-native run-android,在build.gradle文件中出现
1 |
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。 |
1
2
3
4
5
6
7
|
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << “-Xlint:unchecked” << “-Xlint:deprecation”
}
}
}
|
参考链接
- android出现注: 某些输入文件使用或覆盖了已过时的 API。 注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。 注: 某些输入文件使用了未经检查或不安全的操作。 注
11.Error:(64, 31) 警告: [unchecked] 未经检查的转换 需要: Map<String,Object> 找到: Map
添加
1 |
@SuppressWarnings(“unchecked”)
|
参考链接
12.
1
2
|
ld: library not found for -lRNDeviceInfo-tvOS
clang: error: linker command failed with exit code 1 (use -v to see invocation)
|
移除-lRNDeviceInfo-tvOS
参考链接:
13.
1 |
Unhandled JS Exception: Missing Realm constructor. Did you run “react-native link realm”? Please see https://realm.io/docs/react-native/latest/#missing-realm-constructor for troubleshooting
|
在realm/lib/index.js中添加
1
2
3
|
if (typeof atob !== ‘undefined’) {
return ‘chromedebugger’;
}
|
14.出现如下错误,如果使用shadowscks,关闭或选择自动代理。
1
2
3
|
No bundle URL present.
Make sure you’re running a packager server or have included a .jsbundle file in your application bundle.
|
参考链接
15.出现以下是因为没有引入libART.a图形库,这个需要手动导入
1
2
|
ExceptionsManager.js:73 No component found for view with name “ARTShape”
ExceptionsManager.js:73 No component found for view with name “ARTSurfaceView”
|
1).使用xcode中打开react-native中的ios项目,选中‘Libraries’目录 ——> 右键选择‘Add Files to 项目名称’ ——> ‘node_modules/react-native/Libraries/ART/ART.xcodeproj’ 添加;
2).选中项目根目录 ——> 点击’Build Phases‘ ——> 点击‘Link Binary With Libraries’ ——> 点击左下方‘+’ ——> 选中‘libART.a’添加。
参考链接:
- react native 常见问题总结
- react native ios添加ART.xcodeproj(ReactNative No component found for view with name “ARTSurfaceView”)
16.编译出现”_BZ2_bzRead”, referenced from:”
在工程target的Build Phases->Link Binary with Libraries中加入libz.tbd、libbz2.1.0.tbd
参考链接
17.使用realm停止在Downloading XXXXXX
这是因为某些原因影响到下载,可以手动下载,运行 ‘open $TMPDIR’,将下载文件拷贝其中,如果下载逻辑中有对时间的判断还需要处理下,可以根据下载文件忽略
参考链接
18.
1
2
3
4
5
|
Bundling `index.ios.js` [development, non-minified] 0.0% (0/1), failed.
error: bundling failed: ambiguous resolution: module `/Users/bingbing/Poem/PoemRN/index.ios.js` tries to require `react-native`, but there are several files providing this module. You can delete or fix them:
* `/Users/bingbing/Poem/PoemRN/node_modules/autoresponsive-react-native/node_modules/react-native/package.json`
* `/Users/bingbing/Poem/PoemRN/node_modules/react-native/package.json`
|
运行
1 |
yarn start –reset-cache
|
若依据无效可能是升级失败造成,尝试重新升级
参考链接
19.Could not determine java version from ‘9.0.1’.,这是由于本机安装的jdk版本过高,需要切换到低一些的版本
参考链接
20.Caused by: java.lang.UnsupportedOperationException: Can’t convert to color: type=0x1
在android工程中添加color文件
参考链接
21.提交小米应用商店 monkey测试出现
1
2
|
java.lang.NullPointerException: Attempt to invoke virtual method ‘java.io.File java.io.File.getParentFile()’ on a null object reference, stack:
|
应该是react-native-fetch-blob的一个bug
修改文件路径:[project]/node_modules/react-native-fetch-blob/android/src/main/java/com/RNFetchBlobFS
将
1
2
|
- res.put(“SDCardApplicationDir”,ctx.getExternalFilesDir(null).getParentFile().getAbsolutePath());
|
修改为java
+ File externalFilesDir = ctx.getExternalFilesDir(null);
+ if(externalFilesDir != null) {
+ res.put("SDCardApplicationDir", externalFilesDir.getParentFile().getAbsolutePath());
+ } else {
+ res.put("SDCardApplicationDir", Environment.getExternalStorageDirectory().getAbsolutePath());
+ }
参考链接
– fixed getExternalFilesDir null issue