一、报错

Warning:Navigator:isMounted is deprecated. Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to
prevent memory leaks.

原因解析:

isMounted 被弃用

解决方案:

1、

npm install React-native-deprecated-custom-components --save

2、

import Navigator from 'react-native-deprecated-custom-components';

3、用到的地方使用

<Navigator.Navigator
initialRoute={{ name: defaultName, component: defaultComponent }}
configureScene={(route) => {
return Navigator.Navigator.SceneConfigs.VerticalDownSwipeJump;
}}
renderScene={(route, navigator) => {
let Component = route.component;
return <Component {...route.params} navigator={navigator} />
}}
/>

4、千万记得使用Navigator.Navigator,我一直直接使用<Navigator></Navigator>,总是报错,
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components)
but got: object.

这表明没有找到Navigator组件,查了好半天才找到问题所在。

5、或者使用这种方式:

import CustomerComponents, {Navigator} from 'react-native-deprecated-custom-components';

<Navigator></Navigator>

二、报错

Warning:Failed prop type: Invalid prop `style` of type `string` supplied to `Text`, expected `object`

原因解析:

style 类型出错, 不应该是string类型, 应该是object类型

解决方案:

将 style="styles.face" ,该为 style={styles.face}

三、react-native run-android 报错

Error: Cannot create directory C:\Users\Administrator\Desktop\react-native\GD\an droid\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values
:app:mergeDebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Error: Cannot create directory C:\Users\Administrator\Desktop\react-native\GD\ android\app\build\intermediates\incremental\mergeDebugResources\merged.dir\value s

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 1 mins 58.56 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

原因解析:

手机安全和隐私设置,默认禁止安装未知来源的应用

解决方案:

安全和隐私 --  未知来源 -- 允许安装来自未知来源的应用

四、 react-native run-android 失败

04:12:06 E/adb: Unable to obtain result of 'adb version'
:app:installDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: Could not create ADB Bridge. ADB location: D:\adt\sdk\platform-tools\adb.exe

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 1 mins 38.099 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

原因解析:

解决方案:

五、react-native run-android 失败

:app:mergeDebugResources
Error: Cannot create directory C:\Users\Administrator\Desktop\market\XMGBuy\andr oid\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values
:app:mergeDebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Error: Cannot create directory C:\Users\Administrator\Desktop\market\XMGBuy\an droid\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values

原因解析:

解决方案:

react-native 常见问题 及 解决方案的更多相关文章

  1. 【RN - 基础】之React Native常见问题及解决方案

    unable to load script from assets index.android.bundle... 问题原因: 找不到Android项目中的assets文件夹. 解决方案: 1.在An ...

  2. React Native 常见问题集合

    在使用React Native时候,我记录下比较常遇到的问题,分为以下几类: 1. 调试问题 2. 写法问题 3. 疑难问题 4. 奇怪问题 调试问题 1. 在react-native run-and ...

  3. React Native图片缓存解决方案

    1. react-native-fetch-blob 将图片存在本地的一个东西 2. react-native-img-cache 自动缓存的一个东西 上面装好后 就可以使用啦 import {Cac ...

  4. React Native实践之携程Moles框架

    编者:本文来自携程框架研发部高级经理魏晓军在第二期[携程技术微分享]上的分享,以下为整理后的文字实录.视频回放可点击这里.关注携程技术中心微信公号ctriptech,可获知更多微分享课程信息. 因为支 ...

  5. React Native之携程Moles框架

    因为支持用javascript开发原生应用,React Native一推出就受到不少公司热捧,各家都跃跃欲试.但有一个痛点是,在移动端,我们是否有必要开发多套程序:iOS.Android和H5?本次将 ...

  6. 从React Native到微服务,落地一个全栈解决方案

    Poplar是一个社交主题的内容社区,但自身并不做社区,旨在提供可快速二次开发的开源基础套件.前端基于React Native与Redux构建,后端由Spring Boot.Dubbo.Zookeep ...

  7. React Native Android启动白屏的一种解决方案上

    我们用RN去开发Android应用的时候,我们会发现一个很明显的问题,这个问题就是启动时每次都会有1~3秒的白屏时间,直到项目加载出来 为什么会出现这个问题? RN开发的应用在启动时,首先会将js b ...

  8. <React Native移动开发实战>-1-React Native的JSX解决方案

    JSX并不是一门新的开发语言,而是Facebook提出的语法方案:一种可以在JavaScript代码中直接书写HTML标签的语法糖,所以,JSX本质上还是JavaScript语言. 小知识:语法糖(S ...

  9. React Native自适应设备宽度解决方案

    px:设备实际像素单位 dp/pt:逻辑像素单位(IOS的尺寸单位为pt,Android的尺寸单位为dp) 在设计和开发过程中,应该尽量使用逻辑像素尺寸来思考界面. UI 给默认 640 的图,采用 ...

  10. react native的环境搭建中常见问题

    搭建完成android的环境,我们就可以继续我们的react native环境的搭建了. 当然,按照fb的安装流程来完成rn的搭建. http://facebook.github.io/react-n ...

随机推荐

  1. glOrthof 与glFrustumf

    http://www.java123.net/v/533543.html glViewport()函数和glOrtho()函数的理解(转) 在OpenGL中有两个比较重要的投影变换函数,glViewp ...

  2. JAVA泛型练手

    公司电脑不能安装JAVA环境,不爽啊. import java.util.List; import java.util.ArrayList; import java.lang.reflect.Meth ...

  3. ASP.NET MVC4 MVC 当前上下文中不存在名称“Scripts”

    Views目录下的web.config文件 <pages>下<namespaces>下 加入<add namespace="System.Web.Optimiz ...

  4. codeforces-574B

    题目连接:http://codeforces.com/contest/574/problem/B B. Bear and Three Musketeers time limit per test 2 ...

  5. 洛谷 P1048 采药【裸01背包】

    题目描述 辰辰是个天资聪颖的孩子,他的梦想是成为世界上最伟大的医师.为此,他想拜附近最有威望的医师为师.医师为了判断他的资质,给他出了一个难题.医师把他带到一个到处都是草药的山洞里对他说:" ...

  6. 第13届景驰-埃森哲杯广东工业大学ACM程序设计大赛 B题 跳一跳,很简单的(字符串Hash + 树上路径倍增)

    题目链接  2018广东工业大学校赛  Problem B 考虑到每条边的权值变化$26$个时刻之后一定会回到原来的状态. 那么预处理出前$26$个时刻每棵树的形态,对每棵树做一遍字符串哈希. 查询的 ...

  7. [Luogu1429]平面最近点对(加强版)

    题目大意: 平面最近点对. 思路: 分治. 首先将所有点排序 每次把当前区间分为两半,递归求解两个区间内部的情况,然后枚举区间两边的点. #include<cmath> #include& ...

  8. 2.3多线程(java学习笔记)synchronized关键字

    一.为什么要用synchronized关键字 首先多线程中多个线程运行面临共享数据同步的问题. 多线程正常使用共享数据时需要经过以下步骤: 1.线程A从共享数据区中复制出数据副本,然后处理. 2.线程 ...

  9. 十. 图形界面(GUI)设计4.面板

    面板有两种,一种是普通面板(JPanel),另一种是滚动面板(JScrollPane). JPanel 面板是一种通用容器,JPanel的作用是实现界面的层次结构,在它上面放入一些组件,也可以在上面绘 ...

  10. apache去掉目录浏览

    apache去掉目录浏览 apache默认开启目录浏览的,这样大大降低了我们网站的安全,下面是关闭浏览目录: 要禁止 Apache 显示目录结构列表,只需将 Option 中的 Indexes 去掉即 ...