Reputation: 1452
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).
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)
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
Upvotes: 37
Views: 27406
Reputation: 103
This was an interesting error. It took me a whole day to get around it. I tried adding the ndk.abiFilters
as per the answers on here but this alone didn't solve my problem (at least not for my case). I tried building the app in release mode using flutter build apk --release
and it built the apk without any problem. That is when I realized that the issue might be from the emulator itself (I was using a Pixel 2 API 30). So I tried running the app on a real device (Samsung M30) and it ran without any problem. I then became sure that this was definitely from my emulator (besides to the build.gradle config listed on here). The issue was solved when upgraded my emulator to Pixel 4XL API 33 (x64).
Just incase you need it, I have also arranged the ndk.abiFilters as mentioned on here (since I want the app to be built on both x86 and x64 arm models). I setup mine as follow:
...
defaultConfig{
ndk {
abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86_64'
}
}
...
Upvotes: 1
Reputation: 513
I have get this problem now and after searching, trying many time I resolved it I note here to hope can help anyone hit case like me.
My case:
Resolved:
build apk --release
with no connected device and it generate new apk file about 95MB. this apk can run all mode I need.Upvotes: 0
Reputation: 1
In my case error was at play market testing, and adding: android:exported="true"
in AndroidManifest, helped
Upvotes: 0
Reputation: 508
Add following code under the buildTypes in android\app\build.gradle
buildTypes {
release {
ndk {
abiFilters 'armeabi-v7a','arm64-v8a','x86_64'
}
}
}
When building your application in release mode, Flutter apps can be compiled for armeabi-v7a (ARM 32-bit), arm64-v8a (ARM 64-bit), and x86-64 (x86 64-bit). Flutter does not currently support building for x86 Android (See Issue 9253).
Source: https://docs.flutter.dev/deployment/android
Upvotes: 33
Reputation: 141
in app level build.gradle following line should be added
defaultConfig {
...
ndk { abiFilters "armeabi", "x86", "armeabi-v7a","x86_64", "mips",
"mips64", "arm64-v8a" }
}
Upvotes: 9
Reputation: 177
Just in case, someone out there may find this useful, if like me they stumble on this thread while almost losing their minds for 2 days!
Background: I upgraded to AndroidX and was trying to integrate Braze's flutter plugin which is dependent on firebase.
What finally worked: I removed the following dependencies from the app/build.gradle
implementation "com.google.firebase:firebase-core:17.0.1"
implementation "com.google.firebase:firebase-messaging:19.0.1"
And added the following dependencies to pubspec.yaml
firebase_core: ^0.4.0+8
firebase_messaging: ^5.1.2
I suspect there is something in there that makes it fail, not sure, but this worked for me in resolving this issue. If you encounter a similar issue, it maybe be helpful to check your dependencies on Android's build.gradle and flutter's pubspec.yaml.
Upvotes: 2
Reputation: 14145
This is because Flutter used to make an APK compatible with either 32-bit or 64-bit but not both.
However, the issue is resolved by Flutter team recently. Upgarde/Switch to flutter master channel (if you aren't using it). Now, a single command flutter build apk
will produce the apk compatible with both 32-bit and 64-bit architecture. To switch to master channel use command flutter channel master
. And flutter upgrade
to upgrade the flutter sdk.
Upvotes: -3
Reputation: 1452
Solution is described in this article. https://medium.com/flutterpub/flutter-app-couldnt-find-libflutter-so-c95ad81cbccd
TL;DR;
In build.gradle of app this lines should be added:
android {
...
defaultConfig {
....
ndk {
abiFilters 'armeabi-v7a'
}
}
Build should be made using flutter build apk
Upvotes: -4