flutter_mlkit icon indicating copy to clipboard operation
flutter_mlkit copied to clipboard

Release Mode Android | couldn't find "libflutter.so"

Open lance-blo opened this issue 5 years ago • 28 comments

Hi all,

I'm having an issue when using the library and building a release apk for Android.

flutter -v doctor

[√] Flutter (Channel beta, v0.7.3, on Microsoft Windows [Version 10.0.17134.285], locale fr-FR) • Flutter version 0.7.3 at C:\Users\lance\Dev\SDK\flutter • Framework revision 3b309bda07 (3 weeks ago), 2018-08-28 12:39:24 -0700 • Engine revision af42b6dc95 • Dart version 2.1.0-dev.1.0.flutter-ccb16f7282

[√] Android toolchain - develop for Android devices (Android SDK 28.0.2) • Android SDK at C:\Users\lance\AppData\Local\Android\sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-28, build-tools 28.0.2 • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02) • All Android licenses accepted.

[√] Android Studio (version 3.1) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin version 28.0.1 • Dart plugin version 173.4700 • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)

[√] IntelliJ IDEA Community Edition (version 2018.2) • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.1.5 • Flutter plugin version 28.0.4 • Dart plugin version 182.4323.44

[√] Connected devices (1 available) • ONEPLUS A3003 • 94e1fa9b • android-arm64 • Android 8.0.0 (API 26)

• No issues found!

Reproduce issue

  1. Create an empty flutter project

  2. Replace main.dart with

https://pub.dartlang.org/packages/mlkit#-example-tab-

  1. Update pubspec.yaml to

mlkit: ^0.6.2 image_picker:

  1. run $ flutter build apk

  2. I am getting the following

AndroidRuntime: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/eu.my-domain.mlkit-test-VnjMxahfeCGMItX8kAUbAg==/base.apk"],nativeLibraryDirectories=[/data/app/eu.my-domain.mlkit-test-VnjMxahfeCGMItX8kAUbAg==/lib/arm64, /data/app/eu.my-domain.mlkit-test-VnjMxahfeCGMItX8kAUbAg==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]] couldn't find "libflutter.so"

This seems to be linked to https://github.com/flutter/flutter/issues/18939 https://github.com/flutter/flutter/issues/18494

Any ideas why this is hapenning?

lance-blo avatar Sep 15 '18 08:09 lance-blo

Hi,

when you build apk, try the command. flutter build apk --release --target-platform android-arm64

if you still have the same 'couldn't find "libflutter.so"' error, your device could be 32bit.

in that case, change your android build.gradle file something like below. build.gradle defaultConfig { ndk{ abiFilters "armeabi-v7a" } … }

and try the command below. flutter build apk --release --target-platform android-arm

sayurikunugi avatar Sep 15 '18 08:09 sayurikunugi

Thanks. Right, as described here flutter/issues/18939, this makes the app run.

But my problem is that I will not be able to publish the app to the PlayStore as I will be targeting only one architecture.

I have tested several other plugins that are not creating the described problem.

Any ideas as to why this is happening?

lance-blo avatar Sep 15 '18 08:09 lance-blo

Hi, Thanks reporting and commenting!

I'll check it later ASAP! 😄

azihsoyn avatar Sep 15 '18 08:09 azihsoyn

that's true. my app works fine both for 64-bit and 32-bit, when using 32bit build. how about yours?

sayurikunugi avatar Sep 15 '18 09:09 sayurikunugi

Ok after several testing I have the below (my device is 64-bit).

Targeting 64-bit architecture does work. flutter build apk --release --target-platform android-arm64

However targeting 32-bit reproduces the issue. flutter build apk --release --target-platform android-arm

To get the 32-bit version running I need to use: defaultConfig { ndk{ abiFilters "armeabi-v7a" } }

lance-blo avatar Sep 15 '18 09:09 lance-blo

Is there any update on this?

Albert221 avatar Nov 19 '18 18:11 Albert221

Hi, @Albert221

https://github.com/azihsoyn/flutter_mlkit/issues/36#issuecomment-421543617 does not resolve your issue?

azihsoyn avatar Nov 20 '18 00:11 azihsoyn

Hi,

when you build apk, try the command. flutter build apk --release --target-platform android-arm64

if you still have the same 'couldn't find "libflutter.so"' error, your device could be 32bit.

in that case, change your android build.gradle file something like below. build.gradle defaultConfig { ndk{ abiFilters "armeabi-v7a" } … }

and try the command below. flutter build apk --release --target-platform android-arm

This works for me! Thank you sooooooooo much!

RockCoder7 avatar Dec 02 '18 13:12 RockCoder7

Ok after several testing I have the below (my device is 64-bit).

Targeting 64-bit architecture does work. flutter build apk --release --target-platform android-arm64

However targeting 32-bit reproduces the issue. flutter build apk --release --target-platform android-arm

To get the 32-bit version running I need to use: defaultConfig { ndk{ abiFilters "armeabi-v7a" } }

hey , so first thank you , second does that mean I have to produce two different apks? or the first command is enough for the two versions ? EDIT : arm-64 is backwards compatible , so using the abifilters and choosing only armeabi-v7a will work on all devices , unless you have an app that uses something specific to arm64 devices , then you have to make two apks , an apk for every platform, I guess you can declare this issue as solved

phaylali avatar Jan 03 '19 18:01 phaylali

@afamobius What's your minSdkVersion?

kelvinji2009 avatar Jan 14 '19 04:01 kelvinji2009

@afamobius So is it backwards compatible without defaultConfig { ndk{ abiFilters "armeabi-v7a" } } or you needed that for it to be backwards compatible?

shoxter avatar Jan 19 '19 17:01 shoxter

any solution? i have upgrade flutter to 1.7.4 still app crash while open.

dhaval0122 avatar Jun 20 '19 14:06 dhaval0122

After Upgraded flutter to 1.7.4 new error comes how to resolve this in flutter version?

> **/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_image-1.0.0/lib/network.dart:75:31: Error: The argument type 'Null Function(StringBuffer)' can't be assigned to the parameter type 'Iterable<DiagnosticsNode> Function()'.
>  - 'StringBuffer' is from 'dart:core'.                                  
>  - 'Iterable' is from 'dart:core'.                                      
>  - 'DiagnosticsNode' is from 'package:flutter/src/foundation/diagnostics.dart'**

_

nimesh1997 avatar Jun 22 '19 09:06 nimesh1997

this works for me defaultConfig { ndk { abiFilters 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'mips', 'mips64', 'arm64-v8a' } }

amreniouinnovent avatar Sep 02 '19 04:09 amreniouinnovent

After none of the solutions above worked for me, i looked into the documentation and found that it worked fine when i ran flutter build apk --split-per-abi and picked the release-apk corresponding to my system architecture.

marvinsxtr avatar Oct 01 '19 01:10 marvinsxtr

still getting same issue with new flutter version even the pp bundle contin both 32 and 64

Fatal Exception: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/kw.ltd.instagram_app-qzaBIcobpGp9vljkJD7Y1Q==/base.apk"],nativeLibraryDirectories=[/data/app/kw.ltd.instagram_app-qzaBIcobpGp9vljkJD7Y1Q==/lib/arm64, /system/lib64, /vendor/lib64, /system/product/lib64]]] 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.embedding.engine.loader.FlutterLoader.startInitialization(FlutterLoader.java:122) at io.flutter.embedding.engine.loader.FlutterLoader.startInitialization(FlutterLoader.java:93) at io.flutter.view.FlutterMain.startInitialization(FlutterMain.java:45) at io.flutter.app.FlutterApplication.onCreate(FlutterApplication.java:22) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1189) 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(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

kw2019ltd avatar Mar 07 '20 07:03 kw2019ltd

still getting same issue with new flutter version even the pp bundle contin both 32 and 64

Fatal Exception: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/kw.ltd.instagram_app-qzaBIcobpGp9vljkJD7Y1Q==/base.apk"],nativeLibraryDirectories=[/data/app/kw.ltd.instagram_app-qzaBIcobpGp9vljkJD7Y1Q==/lib/arm64, /system/lib64, /vendor/lib64, /system/product/lib64]]] 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.embedding.engine.loader.FlutterLoader.startInitialization(FlutterLoader.java:122) at io.flutter.embedding.engine.loader.FlutterLoader.startInitialization(FlutterLoader.java:93) at io.flutter.view.FlutterMain.startInitialization(FlutterMain.java:45) at io.flutter.app.FlutterApplication.onCreate(FlutterApplication.java:22) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1189) 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(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

Same..

aldwnesx avatar Mar 28 '20 04:03 aldwnesx

this works for me defaultConfig { ndk { abiFilters 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'mips', 'mips64', 'arm64-v8a' } }

do you run build appbundle or apk or splitapk ?

aldwnesx avatar Mar 28 '20 04:03 aldwnesx

We need fix from the flutter team

On Sat, Mar 28, 2020, 07:20 aldwnesx [email protected] wrote:

this works for me defaultConfig { ndk { abiFilters 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'mips', 'mips64', 'arm64-v8a' } }

do you run build appbundle or apk or splitapk ?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/azihsoyn/flutter_mlkit/issues/36#issuecomment-605392374, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALJEI6XUX65EMVPKSESAE73RJV3H5ANCNFSM4FVJBN6A .

kw2019ltd avatar Mar 28 '20 04:03 kw2019ltd

Hello. Trying to build flutter app for x86 32 bit, but libflutter.so is not generated. How can i fix this?

armv7, arm46 and x86_64 are generated without issues

Dvl-es avatar Apr 03 '20 13:04 Dvl-es

Any fixes guys :( ?

devDeejay avatar May 07 '20 12:05 devDeejay

I have the same problem. I've tried to add

ndk{
abiFilters "armeabi-v7a"
}

but after adding this line in build.gradle then my app doesn't work on x86 emulators.

z85510 avatar Jun 11 '20 20:06 z85510

Getting this in production. Not cool.

Fatal Exception: java.lang.UnsatisfiedLinkError dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.seachangedigital.quiverus-1/base.apk"],nativeLibraryDirectories=[/data/app/com.seachangedigital.quiverus-1/lib/x86, /system/lib, /vendor/lib]]] couldn't find "libflutter.so" java.lang.Runtime.loadLibrary0 (Runtime.java:984) java.lang.System.loadLibrary (System.java:1582) io.flutter.embedding.engine.loader.FlutterLoader.startInitialization io.flutter.embedding.engine.loader.FlutterLoader.startInitialization io.flutter.view.FlutterMain.startInitialization io.flutter.app.FlutterApplication.onCreate android.app.Instrumentation.callApplicationOnCreate (Instrumentation.java:1024) android.app.ActivityThread.handleBindApplication (ActivityThread.java:5405) android.app.ActivityThread.-wrap2 (ActivityThread.java) android.app.ActivityThread$H.handleMessage (ActivityThread.java:1546) android.os.Handler.dispatchMessage (Handler.java:102) android.os.Looper.loop (Looper.java:154) android.app.ActivityThread.main (ActivityThread.java:6121) java.lang.reflect.Method.invoke (Method.java) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:889) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:779)

Firebase Crashlytics says the devices are Android 7.1.2 (TaintArt for x86) and 8.1.0 (Nexus 5X)

emadd avatar Jun 14 '20 18:06 emadd

Getting the same error as @emadd .. any solution this my filter setting -- abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'

premtemp1 avatar Jun 18 '20 12:06 premtemp1

I'm integrating flutter in some existing app and I have the same error /base.apk!/lib/x86_64, /system/lib64]]] couldn't find "libflutter.so" at java.lang.Runtime.loadLibrary0(Runtime.java:1012) at java.lang.System.loadLibrary(System.java:1669) And this doesn't solve the problem: ndk { abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64' } I can build a release apk, but I can't run it on emulador using Android Studio.

rlecheta avatar Jul 14 '20 12:07 rlecheta

I have the same issue with Android 5.1 and 5.1.1: nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "libflutter.so" I have used it. buildTypes { release { // other configs ndk { abiFilters 'armeabi-v7a','arm64-v8a','x86_64' } signingConfig signingConfigs.release } targetSdkVersion 29

uzumaki258 avatar Sep 09 '20 07:09 uzumaki258

Same here, tested all configurations proposed. 2 years and still open.

DaBlitzStein avatar Oct 27 '20 00:10 DaBlitzStein

Still not working...missing libflutter.so from x86 Flutter 2.8.1

blamath20 avatar Jan 14 '22 05:01 blamath20