Skip to content

Flutter app drops java.lang.UnsatisfiedLinkError #23055

Closed

Description

@AlexBacich

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

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

The only log I have from GooglePlay:

 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)

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

Flutter doctor gives no issues:

[✓] Flutter (Channel beta, v0.8.2, on Mac OS X 10.13.6 17G65, locale en-UA)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.2)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.0)
[✓] Android Studio (version 3.1)
[✓] VS Code (version 1.28.0)
[✓] Connected devices (1 available)

Activity

  1. added
    c: crashStack traces logged to the console
    engineflutter/engine related. See also e: labels.
    on Oct 15, 2018
  2. added this to the milestone on Oct 15, 2018
  3. AlexBacich commented on Oct 19, 2018

    @AlexBacich
    Author

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

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

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

    Build should be made using flutter build apk

  4. rlee1990 commented on Oct 27, 2018

    @rlee1990

    Looks like I had the same issue. This bug really needs to be fixed.
    My issue #23627

  5. added
    customer: crowdAffects or could affect many people, though not necessarily a specific customer.
    toolAffects the "flutter" command-line tool. See also t: labels.
    t: gradle"flutter build" and "flutter run" on Android
    and removed
    engineflutter/engine related. See also e: labels.
    on Oct 30, 2018
  6. Hixie commented on Oct 30, 2018

    @Hixie
    Contributor
  7. Hixie commented on Nov 14, 2018

    @Hixie
    Contributor
  8. jason-simmons commented on Nov 14, 2018

    @jason-simmons
    Member

    Android does not support loading 32-bit and 64-bit ARM native libraries within the same process. If your app includes another 32-bit library, then the app's build scripts will need to explicitly select the 32-bit version of Flutter.

    Alternatively, the app could include both 32-bit and 64-bit versions of Flutter within the same package. But that will increase the size of the APK.

  9. rockwotj commented on Nov 20, 2018

    @rockwotj

    Instead of only having a certain arch, #24440 would be the ideal solution to this.

  10. Hixie commented on Nov 21, 2018

    @Hixie
    Contributor

    If Android bundles do resolve this, that does seem like the better solution. Let's wait for #24440 to be fixed before doing further work here.

  11. 15 remaining items

  12. GyuriMajercsik commented on Aug 15, 2019

    @GyuriMajercsik

    We got the following exception in production ~13 times from two devices:

    • Huawei P8 (HWGRA), Android 6.0
    • Asus ZenFone 2 (ZE500CL) (ASUS_Z00D), Android 5.0
    java.lang.UnsatisfiedLinkError: 
      at java.lang.Runtime.loadLibrary (Runtime.java:366)
      at java.lang.System.loadLibrary (System.java:989)
      at io.flutter.view.FlutterMain.startInitialization (FlutterMain.java)
      at io.flutter.view.FlutterMain.startInitialization (FlutterMain.java)
      at io.flutter.app.FlutterApplication.onCreate (FlutterApplication.java)
      at android.app.Instrumentation.callApplicationOnCreate (Instrumentation.java:1011)
      at android.app.ActivityThread.handleBindApplication (ActivityThread.java:4550)
      at android.app.ActivityThread.access$1500 (ActivityThread.java:147)
      at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1342)
      at android.os.Handler.dispatchMessage (Handler.java:102)
      at android.os.Looper.loop (Looper.java:135)
      at android.app.ActivityThread.main (ActivityThread.java:5253)
      at java.lang.reflect.Method.invoke (Method.java)
      at java.lang.reflect.Method.invoke (Method.java:372)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:949)
      at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:744)
    

    The release was built with flutter build appbundle, so it should contain both 32 and 64 bit versions. The used Flutter version is: Flutter 1.7.8+hotfix.4 channel stable.

  13. gofur commented on Aug 16, 2019

    @gofur

    i got same errors ?? any update ? @pranayairan or others can help??

    Asus ZenFone 2 (ZE550ML) (Z008_1), Android 5.0

    java.lang.UnsatisfiedLinkError: at java.lang.Runtime.loadLibrary (Runtime.java:366) at java.lang.System.loadLibrary (System.java:989) at io.flutter.view.FlutterMain.startInitialization (FlutterMain.java:122) at io.flutter.view.FlutterMain.startInitialization (FlutterMain.java:99) at io.flutter.app.FlutterApplication.onCreate (FlutterApplication.java:22) at android.app.Instrumentation.callApplicationOnCreate (Instrumentation.java:1011) at android.app.ActivityThread.handleBindApplication (ActivityThread.java:4550) at android.app.ActivityThread.access$1500 (ActivityThread.java:147) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1342) at android.os.Handler.dispatchMessage (Handler.java:102) at android.os.Looper.loop (Looper.java:135) at android.app.ActivityThread.main (ActivityThread.java:5253) at java.lang.reflect.Method.invoke (Native Method) at java.lang.reflect.Method.invoke (Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:900) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:695)

  14. Row7 commented on Sep 10, 2019

    @Row7

    Same problem here with these devices:

    • Samsung Galaxy Note9 (crownlte), Android 9
    • Samsung Galaxy J6 (j6lte), Android 9
    • Samsung Galaxy Tab A 8.0 (gtasliteltecs), Android 9

    The release was built with flutter build appbundle on stable channel.

  15. zanderso commented on Sep 10, 2019

    @zanderso
    Member

    @blasten Would you mind taking a quick look at this one to see if there's any new advice in light of your recent work. Thanks!

  16. davidmartos96 commented on Sep 14, 2019

    @davidmartos96
    Contributor

    @Row7 What version of Flutter is it? 1.7.8 or 1.9.1?

  17. Row7 commented on Sep 14, 2019

    @Row7

    @Row7 What version of Flutter is it? 1.7.8 or 1.9.1?

    1.7.8

  18. mohlam12 commented on Sep 16, 2019

    @mohlam12

    Same problem on emulator when deploying a release-built apk (without even spliting per abis)

    FATAL EXCEPTION: main Process: XXXXXXXX, PID: 9530 java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/XXXXXXXX-iYKv7sNLXGEKuJRp42Y1YA==/base.apk"],nativeLibraryDirectories=[/data/app/XXXXXXXX-iYKv7sNLXGEKuJRp42Y1YA==/lib/x86, /data/app/XXXXXXXX-iYKv7sNLPGEKuJRp42Y1YA==/base.apk!/lib/x86, /system/lib, /system/product/lib]]] couldn't find "libflutter.so"

    at java.lang.Runtime.loadLibrary0(Runtime.java:1067)
    at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
    at java.lang.System.loadLibrary(System.java:1667)
    at io.flutter.view.FlutterMain.startInitialization(Unknown Source:34)
    at io.flutter.view.FlutterMain.startInitialization(Unknown Source:10)
    at io.flutter.app.FlutterApplication.onCreate(Unknown Source:3)
    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1182)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6460)
    at android.app.ActivityThread.access$1300(ActivityThread.java:219)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7356)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)`
    
  19. blasten commented on Sep 16, 2019

    @blasten

    @mohlam12 It looks you need an ARM32 or ARM64 emulator if you running a release (fat) APK.

    Update on this issue:

    A few things have changed since this issue was filed, Flutter supports fat APKs, split APK per ABI APKs and App bundles. This currently works for ARM32 and ARM64 devices. Additionally, we plan to add support for x86_64 soon (Follow #9253 for updates. cc @jonahwilliams).

    As a result, I'm closing this issue.

  20. creativecreatorormaybenot commented on Nov 4, 2019

    @creativecreatorormaybenot
    Contributor

    @blasten I do not understand why you closed this. This issue is not fixed and it is the most frequent crash for my app on Android.

    Maybe the work regarding #9253 added the possibility to fix it, however, I do not understand how to do it, i.e. flutter build appbundle does not fix it and I followed these issues, but could not figure out what I can do to include libflutter.so (as it seems that it is not included by default for some devices).

  21. blasten commented on Nov 4, 2019

    @blasten
  22. creativecreatorormaybenot commented on Nov 5, 2019

    @creativecreatorormaybenot
    Contributor

    @blasten I am using Android App Bundles. I might just not understand what you are saying there.

  23. aldwnesx commented on Mar 27, 2020

    @aldwnesx

    FWIW right now what I do is generate APKs (https://developer.android.com/google/play/publishing/multiple-apks#CreatingApks) one of which using --target-platform=android-arm and the other which is --target-platform=android-arm64

    Then I also set the right abiFilter in the Gradle files for each of those. Just a minor bit of hassle to get 64bit libraries for higher end devices.

    how do you publish two different apks version number? i tdoesn't allow me to generate two same version but iw ant to publish both arm and arm64

  24. lock commented on Apr 19, 2020

    @lock

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  25. locked and limited conversation to collaborators on Apr 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: crashStack traces logged to the consolecustomer: crowdAffects or could affect many people, though not necessarily a specific customer.platform-androidAndroid applications specificallyt: gradle"flutter build" and "flutter run" on AndroidtoolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions