常见问题

  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"
            }
        }
    }
Logo

开源鸿蒙跨平台开发社区汇聚开发者与厂商,共建“一次开发,多端部署”的开源生态,致力于降低跨端开发门槛,推动万物智联创新。

更多推荐