You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native 0.70构建成功后Metro启动报错求助

React Native 0.70 安装时出现 libreanimated.so 找不到的解决办法

错误信息

Error: Exception in HostFunction: java.lang.UnsatisfiedLinkError: dlopen failed: library "libreanimated.so" not found


解决步骤

  • 匹配Reanimated版本兼容性:React Native 0.70需搭配Reanimated 2.x系列(推荐2.12.0),执行以下命令调整版本:

    npm uninstall react-native-reanimated
    npm install react-native-reanimated@2.12.0
    
  • 清理并重新构建Android项目:

    cd android
    ./gradlew clean
    ./gradlew assembleDebug
    
  • 确认Reanimated配置正确性:

    1. 打开android/app/build.gradle,确保开启Hermes(Reanimated依赖该引擎):
      project.ext.react = [
        enableHermes: true,
      ]
      
    2. 检查MainApplication.java中是否导入并注册Reanimated包:
      import com.swmansion.reanimated.ReanimatedPackage;
      // ...
      @Override
      protected List<ReactPackage> getPackages() {
        return Arrays.asList(
          new MainReactPackage(),
          new ReanimatedPackage()
        );
      }
      
  • 重置Metro缓存:

    npx react-native start --reset-cache
    
  • 指定兼容的NDK版本:React Native 0.70推荐使用NDK 25,在android/build.gradle中添加配置:

    android {
      ndkVersion = "25.2.9519653"
    }
    

内容的提问来源于stack exchange,提问作者Roger Marsino

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 04:55:29