zoukankan      html  css  js  c++  java
  • react-native 常见问题 及 解决方案

    一、报错

    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:UsersAdministratorDesktop eact-nativeGDan droidappuildintermediatesincrementalmergeDebugResourcesmerged.dirvalues
    :app:mergeDebugResources FAILED

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':app:mergeDebugResources'.
    > Error: Cannot create directory C:UsersAdministratorDesktop eact-nativeGD androidappuildintermediatesincrementalmergeDebugResourcesmerged.dirvalue 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:adtsdkplatform-toolsadb.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:UsersAdministratorDesktopmarketXMGBuyandr oidappuildintermediatesincrementalmergeDebugResourcesmerged.dirvalues
    :app:mergeDebugResources FAILED

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':app:mergeDebugResources'.
    > Error: Cannot create directory C:UsersAdministratorDesktopmarketXMGBuyan droidappuildintermediatesincrementalmergeDebugResourcesmerged.dirvalues

    原因解析:

    解决方案:

  • 相关阅读:
    可视化理解卷积神经网络
    方差 标准差区别
    SSIS中出现数据流数据源假死状态的解决办法
    IIS中ASP.NET虚拟目录不继承主站点web.config设置的办法(转载)
    SSAS 度量值中的distinct count局聚合方式会数为null的值
    SSAS中CUBE的多对多关系既可以出现在中间事实表上也可以出现在中间维度表上
    SSAS中事实表中的数据如果因为一对多或多对多关系复制了多份,在维度上聚合的时候还是只算一份
    获取当前正在执行的Javascript脚本文件的路径
    C#中try catch中throw ex和throw方式抛出异常有何不同
    SqlServer 一个查询语句导致tempdb增大55G(转载)
  • 原文地址:https://www.cnblogs.com/crazycode2/p/7153599.html
Copyright © 2011-2022 走看看