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

安装react-native-screens后出现UnsatisfiedLinkError等问题求助

解决react-native-screens安装后出现的librnscreens.so缺失及App未注册问题

核心问题分析

报错根源是Android原生无法找到react-native-screens的动态链接库librnscreens.so,进而引发后续App未注册的连锁错误,以下是针对性修复步骤:

1. 清理并重新构建原生项目

  • 进入项目android目录,执行清理命令:
    ./gradlew clean
    
  • 返回项目根目录,重新打包运行:
    npx react-native run-android
    

2. 确认react-native-screens的原生配置

  • 执行手动链接命令(适配RN 0.60+自动链接的兼容问题):
    npx react-native link react-native-screens
    
  • 手动检查Android配置文件:
    • 打开android/app/build.gradle,确保dependencies块包含:
      implementation project(':react-native-screens')
      
    • 打开android/settings.gradle,确保包含:
      include ':react-native-screens'
      project(':react-native-screens').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-screens/android')
      

3. 适配Hermes引擎配置

  • 打开android/app/build.gradle,确认Hermes启用配置正确:
    project.ext.react = [
      enableHermes: true, // 使用Hermes需保持为true,禁用则设为false
    ]
    
  • 删除Hermes缓存目录后重新构建:
    删除android/app/build/generated/assets/react/release和android/app/build/generated/sourcemaps/react/release,再执行npx react-native run-android

4. 修复App未注册问题

  • 重启Metro并清除缓存:
    npx react-native start --reset-cache
    
  • 确保Metro运行在项目根目录,不要在子目录启动
  • 检查入口文件(index.js/App.js)的注册代码:
    import { AppRegistry } from 'react-native';
    import App from './App';
    import { name as appName } from './app.json';
    
    AppRegistry.registerComponent(appName, () => App);
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.26 00:43:34