Java自学者论坛

 找回密码
 立即注册

手机号码,快捷登录

恭喜Java自学者论坛(https://www.javazxz.com)已经为数万Java学习者服务超过8年了!积累会员资料超过10000G+
成为本站VIP会员,下载本站10000G+会员资源,会员资料板块,购买链接:点击进入购买VIP会员

JAVA高级面试进阶训练营视频教程

Java架构师系统进阶VIP课程

分布式高可用全栈开发微服务教程Go语言视频零基础入门到精通Java架构师3期(课件+源码)
Java开发全终端实战租房项目视频教程SpringBoot2.X入门到高级使用教程大数据培训第六期全套视频教程深度学习(CNN RNN GAN)算法原理Java亿级流量电商系统视频教程
互联网架构师视频教程年薪50万Spark2.0从入门到精通年薪50万!人工智能学习路线教程年薪50万大数据入门到精通学习路线年薪50万机器学习入门到精通教程
仿小米商城类app和小程序视频教程深度学习数据分析基础到实战最新黑马javaEE2.1就业课程从 0到JVM实战高手教程MySQL入门到精通教程
查看: 586|回复: 0

react-native 常见问题 及 解决方案

[复制链接]
  • TA的每日心情
    奋斗
    4 天前
  • 签到天数: 802 天

    [LV.10]以坛为家III

    2053

    主题

    2111

    帖子

    72万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    积分
    726006
    发表于 2021-6-20 22:33:02 | 显示全部楼层 |阅读模式

    一、报错

    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

     

    原因解析:

    解决方案:

    哎...今天够累的,签到来了1...
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|手机版|小黑屋|Java自学者论坛 ( 声明:本站文章及资料整理自互联网,用于Java自学者交流学习使用,对资料版权不负任何法律责任,若有侵权请及时联系客服屏蔽删除 )

    GMT+8, 2024-11-15 02:05 , Processed in 0.124962 second(s), 30 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2021, Tencent Cloud.

    快速回复 返回顶部 返回列表