请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

在真机上运行闪退

配置完成之后在模拟器上能正常运行,但是在真机上运行闪退,我的手机是小米6,不知道怎么回事,以下是错误信息
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.my_flutter_app, PID: 24853
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file “/data/app/com.example.my_flutter_app-3hPtwJQqNENVa1wyeuofTA==/base.apk”],nativeLibraryDirectories=[/data/app/com.example.my_flutter_app-3hPtwJQqNENVa1wyeuofTA==/lib/arm64, /data/app/com.example.my_flutter_app-3hPtwJQqNENVa1wyeuofTA==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]] couldn’t find "libflutter.so"
at java.lang.Runtime.loadLibrary0(Runtime.java:1011)
at java.lang.System.loadLibrary(System.java:1657)
at io.flutter.view.FlutterMain.startInitialization(FlutterMain.java:156)
at io.flutter.view.FlutterMain.startInitialization(FlutterMain.java:133)
at io.flutter.app.FlutterApplication.onCreate(FlutterApplication.java:22)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5881)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThreadH.handleMessage(ActivityThread.java:1690)atandroid.os.Handler.dispatchMessage(Handler.java:105)atandroid.os.Looper.loop(Looper.java:176)atandroid.app.ActivityThread.main(ActivityThread.java:6701)atjava.lang.reflect.Method.invoke(NativeMethod)atcom.android.internal.os.ZygoteH.handleMessage(ActivityThread.java:1690) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:176) at android.app.ActivityThread.main(ActivityThread.java:6701) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteH.handleMessage(ActivityThread.java:1690)atandroid.os.Handler.dispatchMessage(Handler.java:105)atandroid.os.Looper.loop(Looper.java:176)atandroid.app.ActivityThread.main(ActivityThread.java:6701)atjava.lang.reflect.Method.invoke(NativeMethod)atcom.android.internal.os.ZygoteMethodAndArgsCaller.run(Zygote.java:246)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783)

正在回答 回答被采纳积分+3

1回答

CrazyCodeBoy 2019-05-03 15:49:21

出错的原因在于flutter的架构"libflutter.so"没有打包进去导致的,需要配置下你的build.gradle,这个在课程中有讲到哦:

defaultConfig {
applicationId "org.devio.fluttertrip"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk {
abiFilters "armeabi-v7a","arm64-v8a","x86_64","x86" //只打包flutter所支持的架构,flutter没有armeabi架构的so,加x86的原因是为了能够兼容模拟器
//            abiFilters "armeabi-v7a" //release 时只打"armeabi-v7包
}
}
...
packagingOptions {
// 确保app与asr_plugin都依赖的libflutter.so merge时不冲突@https://github.com/card-io/card.io-Android-SDK/issues/186#issuecomment-427552552
pickFirst 'lib/x86_64/libflutter.so'
pickFirst 'lib/x86/libflutter.so'
pickFirst 'lib/arm64-v8a/libflutter.so'
}

请参考:https://git.imooc.com/coding-321/flutter_trip/src/master/android/app/build.gradle#L47


0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信