Flutter应用会丢弃java.lang.UnsatisfiedLinkError(找不到"libflutter.so") [英] Flutter app drops java.lang.UnsatisfiedLinkError (couldn't find "libflutter.so")

查看:143
本文介绍了Flutter应用会丢弃java.lang.UnsatisfiedLinkError(找不到"libflutter.so")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经构建了一个用Flutter编写的应用程序,并且在我的设备上运行良好.

I've built an app written on Flutter and it's running well on my device.

但是,在客户端设备上,它在启动时崩溃(甚至在Centry启动之前).

On client device however it is crashing at start (even before Centry initiates).

连接到亚行时,我们收到以下日志:

When connected To ADB we got this log:

 AndroidRuntime: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.travel.exchange-1/base.apk"],nativeLibraryDirectories=[/data/app/com.travel.exchange-1/lib/arm, /data/app/com.travel.exchange-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]] couldn't find "libflutter.so"

 at java.lang.Runtime.loadLibrary (Runtime.java:367)
  at java.lang.System.loadLibrary (System.java:1076)
  at io.flutter.view.FlutterMain.startInitialization (FlutterMain.java:172)
  at io.flutter.view.FlutterMain.startInitialization (FlutterMain.java:149)
  at io.flutter.app.FlutterApplication.onCreate (FlutterApplication.java:22)
  at android.app.Instrumentation.callApplicationOnCreate (Instrumentation.java:1037)
  at android.app.ActivityThread.handleBindApplication (ActivityThread.java:6496)
  at android.app.ActivityThread.access$1800 (ActivityThread.java:229)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1887)
  at android.os.Handler.dispatchMessage (Handler.java:102)
  at android.os.Looper.loop (Looper.java:148)
  at android.app.ActivityThread.main (ActivityThread.java:7406)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)

我正在专门使用arm64进行构建(如果我尝试在arm(32)上运行,即使在我的设备上,应用也会崩溃.

I'm building specifically using arm64 (app crashes even on my device if I'm trying to run on arm (32).

flutter build apk --release --target-platform=android-arm64

推荐答案

本文介绍了解决方案. https://medium.com/flutterpub/flutter-app-无法找到libflutter-so-c95ad81cbccd

Solution is described in this article. https://medium.com/flutterpub/flutter-app-couldnt-find-libflutter-so-c95ad81cbccd

TL; DR;

在应用程序的build.gradle中,应添加以下行:

In build.gradle of app this lines should be added:

android {
     ...
    defaultConfig {
       ....    
        ndk {
            abiFilters 'armeabi-v7a'
        }
    }

构建应使用 flutter build apk

这篇关于Flutter应用会丢弃java.lang.UnsatisfiedLinkError(找不到"libflutter.so")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆