Hybrid开发

RN 踩坑记录

2018-10-10  本文已影响496人  OnceWhite
1)android打包apk根据官网操作出现的错误

根据提示路径一步步的查找最终在node-pre-gyp发现几个爆红的文件,这是找不到文件,只要把这几个找不到的文件删掉就可以了(nopt、needle、detct-libc、rc)

2)使用StatusBar后界面显示不出来

给view添加flex:1样式

3)Android使用Animated.View时动画视图显示不出来

给Animated.View进行绝对布局设置

4) 警告 Warning:setState(...):Can only update a mounted or mounting component...

赋值前进行空值判断

5)iOS网络图片无法显示问题

在App Transport Security Settings中添加Allow Arbitrary Loads
设置为YES即可。

6) TextInput无法获取焦点

给TextInput设置高度(height)即可

7) TextInput多行输入文字居中显示问题(需求顶部对其)

设置textAlignVertical:'top'(文本垂直方向布局)属性即可实现下面效果

8) 报错 undefined is not an object (evaluating 'n.View.propTypes.style')

使用ViewPropTypes代替View.propTypes

import PropTypes from 'prop-types';
import ViewPropTypes from 'ViewPropTypes';

static propTypes = {
  style: Text.propTypes.style,
  imgStyle: ViewPropTypes.style,
  titleStyle: PropTypes.any,
  title: PropTypes.string,
  source: PropTypes.any,'
}

9) 在集成react-navigation和redux时 出现TypeError: undefined is not a function (near '...addListener...')错误.

集成该库: react-navigation-redux-helpers

10) 在集成react-navigation和redux时 出现 安卓不显示tabBar图标情况.

在tabBarOptions中添加showIcon: true如:

11) Android报错:Error:found unexpected optical bounds (red pixel) on top border at x=106.

在gradle.properties文件下添加 android.enableAapt2 = false

12) android打包错误:uncompiled PNG file passed as argument. Must be compiled first into .flat file..

添加 org.gradle.configureondemand=trueandroid/gradle.properties

13) android 运行 报错:transformDexWithInstantRunDependenciesApkForDebug

这个问题是setting里面的设置问题:

File---->Settings--->Build,Execution,Deployment---->Instant Run ---->去掉第一个条目的对钩就ok啦

上一篇 下一篇

猜你喜欢

热点阅读