RN 项目异常问题整理

常见问题

  1. 无法找到 CardStackStyleInterpolator
    StackViewStyleInterpolator 这个方法集来代替 CardStackStyleInterpolator的,这个方法集的路径也需要注意一下,在2.12.1版本之前, 该文件在react-navigation/src/views/StackView/中,在更高版本中,该文件已经移到了react-navigation-stack/dist/views/StackView/中
  2. 安装或卸载组件失败,/node_modules/react-native-file-picker: Appears to be a git repo or submodule.
    需要先使用命令:rimraf node_modules ,删除所有组件,然后再安装/卸载之前失败的组件,最后再次执行 npm install
  3. 运行时报错 null is not an object (evaluating '_RNGestureHandlerModule.default.Direction') 
    执行命令: react-native link
  4. npm i 报错:Unexpected end of JSON input while parsing near
    运行  npm cache clean --force,然后再次执行 npm i
  5. 控制台解决报错命令信息
     1. Clear watchman watches: watchman watch-del-all
     2. Delete node_modules and run yarn install
     3. Reset Metro's cache: yarn start --reset-cache
     4. Remove the cache: rm -rf /tmp/metro-*
  6. ReactNative 生成 Android 平台的 bundle 文件
    该文件放在 assets 目录,
    命令一
    node node_modules/react-native/local-cli/cli.js bundle --platform android --dev true --reset-cache --entry-file index.android.js --bundle-output app/src/main/assets/index.android.bundle —sourcemap-output app/src/main/assets/index.android.map —assets-dest app/src/main/res/
    命令 二
    react-native bundle --platform android --dev false --entry-file index.android.js  --bundle-output android/app/src/main/assets/index.android.bundle  --assets-dest android/app/src/main/res/ 
    在执行该命令出现以下异常时:Module scheduler/tracing does not exist in the Haste module map
    需要调整 react-native 版本对应的 react 版本
    重要:每次 js 文件更新或 package.json 更新,都需要 npm i ,然后重新打包 bundle 文件
    参阅:https://www.cnblogs.com/honeynm/p/9007130.html
  7. libgnustl_shared.so" is 32-bit instead of 64-bit
    React Native 项目在 64 位手机运行会提示以上异常,需要使用以下方法处理:
    在项目的根目录的 gradle.properties 里面添加一行代码  android.useDeprecatedNdk=true.
    在 build.gradle 文件里添加以下代码
    android {
        ...
        defaultConfig {
            ...
            ndk {
                abiFilters "armeabi-v7a", "x86"
            }
      
            packagingOptions {
                exclude "lib/arm64-v8a/librealm-jni.so"
            }
        }
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值