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

运行CleanMyMac后React Native Expo Go在Android模拟器崩溃求助

Expo Go在Android模拟器启动失败:libc++_shared.so缺失(CleanMyMac清理后)

问题描述

运行CleanMyMac清理Mac后,React Native Expo Go项目无法在Android模拟器启动,iOS模拟器正常。已尝试清理缓存、重装Node/npm/watchman/expo-cli、更新SDK和APK等操作,问题仍存在。启动Expo Go时logcat报错如下:

E  FATAL EXCEPTION: main
Process: host.exp.exponent, PID: 7381
com.facebook.soloader.SoLoaderDSONotFoundError: couldn't find DSO to load: libc++_shared.so
existing SO sources:
SoSource 0: ApplicationSoSource[DirectorySoSource[root = /data/app/~~X68nSWVOpxXNMBrgAxvs8w==/host.exp.exponent-WTG-WxYgb7RBAQjrPChEig==/lib/arm64 flags = 0]]
SoSource 1: DirectApkSoSource[root = [/data/app/~~X68nSWVOpxXNMBrgAxvs8w==/host.exp.exponent-WTG-WxYgb7RBAQjrPChEig==/base.apk!/lib/arm64-v8a]]
SoSource 2: DirectorySoSource[root = /system/lib64 flags = 3]                                                                                                      
SoSource 3: DirectorySoSource[root = /vendor/lib64 flags = 3]
Native lib dir: /data/app/~~X68nSWVOpxXNMBrgAxvs8w==/host.exp.exponent-WTG-WxYgb7RBAQjrPChEig==/lib/arm64

at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SourceFile:107)                                                                                                    
at com.facebook.soloader.SoLoader.loadLibraryBySoNameImpl(SourceFile:150)                                                                                                      
at com.facebook.soloader.SoLoader.loadDependency(SourceFile:7)                                                                                                     
at com.facebook.soloader.DirectApkSoSource.loadDependencies(SourceFile:32)                                                                                                     
at com.facebook.soloader.DirectApkSoSource.loadLibrary(SourceFile:50)                                                                                                      
at com.facebook.soloader.SoLoader.loadLibraryFromSoSource(SourceFile:4)                                                                                                    
at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SourceFile:61)                                                                                                     
at com.facebook.soloader.SoLoader.loadLibraryBySoNameImpl(SourceFile:150)                                                                                                      
at com.facebook.soloader.SoLoader.loadLibraryBySoName(SourceFile:2)                                                                                                    
at com.facebook.soloader.SoLoader.loadLibraryOnAndroid(SourceFile:27)                                                                                                      
at com.facebook.soloader.SoLoader.loadLibrary(SourceFile:8)                                                                                                    
at com.facebook.soloader.SoLoader.loadLibrary(SourceFile:1)                                                                                                    
at com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsCxxInterop.<clinit>(SourceFile:10)                                                                                                      
at com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsCxxAccessor.override(SourceFile:6)                                                                                                      
at com.facebook.react.internal.featureflags.ReactNativeFeatureFlags.override(SourceFile:8)                                                                                                     
at Qe.f.a(SourceFile:6)                                                                                                    
at Qe.d.onCreate(SourceFile:113)                                                                                                       
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1386)                                                                                                      
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7504)                                                                                                      
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)                                                                                                     
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2416)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loopOnce(Looper.java:232)
at android.os.Looper.loop(Looper.java:317)
at android.app.ActivityThread.main(ActivityThread.java:8705)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)                                                                                                   
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)

设备:MacBook Pro M4

解决方案

1. 修复Android NDK依赖

libc++_shared.so来自NDK,CleanMyMac可能误删或损坏了NDK文件:

  • 打开Android Studio,进入Settings -> Appearance & Behavior -> System Settings -> Android SDK -> SDK Tools
  • 勾选NDK (Side by side),点击"Show Package Details",选择Expo SDK对应的NDK版本(如Expo 50对应NDK 25.2.9519653),重新安装覆盖
  • 确认NDK路径已配置到环境变量:export ANDROID_NDK_HOME=/Users/[你的用户名]/Library/Android/sdk/ndk/[对应版本号]

2. 重置/重建Android模拟器

  • 打开Android Studio的Device Manager,选中当前模拟器,点击... -> Wipe Data清除数据
  • 若无效,删除模拟器,新建arm64-v8a架构的系统镜像(适配M4原生arm64,避免x86转译兼容性问题)

3. 调整Expo项目Android配置

在项目根目录android/app/build.gradle中添加以下配置,确保libc++_shared.so被正确打包:

android {
    defaultConfig {
        ndk {
            abiFilters 'arm64-v8a'
        }
    }
    packagingOptions {
        pickFirst 'lib/arm64-v8a/libc++_shared.so'
    }
}

执行npx expo prebuild --clean重新生成原生文件

4. 彻底清除深层缓存

# 清除Expo缓存
npx expo r -c
# 清除npm缓存
npm cache clean --force
# 清除watchman缓存
watchman watch-del-all
# 删除依赖文件并重装
rm -rf node_modules package-lock.json yarn.lock
npm install

5. 恢复CleanMyMac误删文件

打开CleanMyMac,进入Cleanup -> Logs,查看最近清理记录,恢复被误删的Android SDK/NDK相关文件

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.14 04:50:09