Play预启动报告出现UnsatisfiedLinkError无法找到libflutter.so求助
崩溃日志
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.newversity.android/com.newversity.android.MainActivity}: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/android.test.mock.jar", zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/androidx.test.tools.crawler-_ZTAu_rK0htQZxK8_AK-wQ==/base.apk", zip file "/data/app/com.newversity.android-LvjaRggzo2wdCnt195uXdg==/base.apk", zip file "/data/app/com.newversity.android-LvjaRggzo2wdCnt195uXdg==/split_config.en.apk", zip file "/data/app/com.newversity.android-LvjaRggzo2wdCnt195uXdg==/split_config.x86.apk", zip file "/data/app/com.newversity.android-LvjaRggzo2wdCnt195uXdg==/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/androidx.test.tools.crawler-_ZTAu_rK0htQZxK8_AK-wQ==/lib/x86, /data/app/com.newversity.android-LvjaRggzo2wdCnt195uXdg==/lib/x86, /data/app/androidx.test.tools.crawler-_ZTAu_rK0htQZxK8_AK-wQ==/base.apk!/lib/x86, /data/app/com.newversity.android-LvjaRggzo2wdCnt195uXdg==/base.apk!/lib/x86, /data/app/com.newversity.android-LvjaRggzo2wdCnt195uXdg==/split_config.en.apk!/lib/x86, /data/app/com.newversity.android-LvjaRggzo2wdCnt195uXdg==/split_config.x86.apk!/lib/x86, /data/app/com.newversity.android-LvjaRggzo2wdCnt195uXdg==/split_config.xxhdpi.apk!/lib/x86, /system/lib]]] couldn't find "libflutter.so"
解决方法
配置ABI兼容范围
在android/app/build.gradle的defaultConfig块中添加NDK配置,确保包含崩溃日志中出现的x86架构,同时覆盖主流架构:defaultConfig { // 其他配置... ndk { abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' } }Debug模式默认打包所有ABI不会出问题,但Release/App Bundle默认可能只打包ARM架构,导致x86设备的拆分包缺失libflutter.so。
验证App Bundle拆分包
使用bundletool生成x86架构的APK,安装到x86模拟器上复现预启动场景:# 生成对应ABI的APK集合 bundletool build-apks --bundle=app-release.aab --output=app.apks --abi=x86 # 安装到模拟器 bundletool install-apks --apks=app.apks这样可以在本地确认问题是否存在。
清理缓存重新打包
执行以下命令清理旧缓存后重新构建App Bundle,避免缓存导致的so文件缺失:flutter clean flutter build appbundle --release检查Play Console分发配置
在Google Play Console中,确认没有开启会移除原生库的优化选项,同时保证上传的App Bundle包含所有需要的ABI对应的libflutter.so文件。升级Flutter稳定版
部分旧版本Flutter在打包App Bundle时存在原生库拆分bug,升级到最新稳定版可解决这类问题:flutter upgrade
内容的提问来源于stack exchange,提问作者Naman

