android - Flutter 与现有应用程序崩溃

标签 android flutter

我正在尝试将 Flutter 添加到现有的 Android 应用程序中,但遇到了运行时崩溃。我正在执行以下步骤: https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps .我知道这仍处于测试阶段,在不久的将来可能会变得更好,但我提出这个是希望能帮助其他人,或者万一我错过了一些简单的事情。

当启动我的 FlutterActivity 的 Intent 时,该 Activity 已启动,但随后立即使应用程序崩溃。开始 Activity 看起来像这样:

ComponentName componentName = new ComponentName(getActivity(), "com.example.flutterpart.MainActivity");
Intent intent = new Intent().setComponent(componentName);
startActivity(intent);

这是我使用的 flutter 版本:

$ flutter --version
Flutter 0.4.4 • channel beta • https://github.com/flutter/flutter.git
Framework • revision f9bb4289e9 (4 weeks ago) • 2018-05-11 21:44:54 -0700
Engine • revision 06afdfe54e
Tools • Dart 2.0.0-dev.54.0.flutter-46ab040e58

这是崩溃日志。为了安全起见,为了简短起见,这已经被修改,所以我可能遗漏了一些重要的东西:

I/ActivityManager( 1028): START u0 {cmp=com.sambuo.debug/com.example.flutterpart.MainActivity} from uid 10371 on display 0
V/WindowManager( 1028): addAppToken: AppWindowToken{1d6cd2bf token=Token{1be320de ActivityRecord{20ad6819 u0 com.sambuo.debug/com.example.flutterpart.MainActivity t4763}}} to stack=1 task=4763 at 1
W/linker  (24531): libflutter.so: unused DT entry: type 0x6ffffffe arg 0xd84c
W/linker  (24531): libflutter.so: unused DT entry: type 0x6fffffff arg 0x3
I/FlutterActivityDelegate(24531): onResume app wasn't a FlutterApplication!!
V/WindowManager( 1028): Adding window Window{335d618d u0 com.sambuo.debug/com.example.flutterpart.MainActivity} at 3 of 9 (after Window{368c02b1 u0 com.sambuo.debug/com.sambuo.LoginActivity})
V/WindowManager( 1028): Adding window Window{2711eb53 u0 SurfaceView} at 3 of 10 (before Window{335d618d u0 com.sambuo.debug/com.example.flutterpart.MainActivity})
I/flutter (24531): Observatory listening on http://127.0.0.1:46786/
I/ActivityManager( 1028): Displayed com.sambuo.debug/com.example.flutterpart.MainActivity: +3s945ms (total +25s459ms)
F/google-breakpad(26159): Microdump skipped (uninteresting)
W/google-breakpad(24531): ### ### ### ### ### ### ### ### ### ### ### ### ###
W/google-breakpad(24531): Chrome build fingerprint:
W/google-breakpad(24531): 67.0.3396.68
W/google-breakpad(24531): 339606800
W/google-breakpad(24531): ### ### ### ### ### ### ### ### ### ### ### ### ###
F/libc    (24531): Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 26085 (1.ui)
I/DEBUG   (  431): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG   (  431): Build fingerprint: 'motorola/falcon_gpe/falcon_umts:5.1/LMY47M.M005/10:user/release-keys'
I/DEBUG   (  431): Revision: '33728'
I/DEBUG   (  431): ABI: 'arm'
I/DEBUG   (  431): pid: 24531, tid: 26085, name: 1.ui  >>> com.sambuo.debug <<<
I/DEBUG   (  431): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
I/DEBUG   (  431):     r0 00000000  r1 ffffffff  r2 99ef379c  r3 b7c758ac
I/DEBUG   (  431):     r4 b7c75868  r5 99ef379c  r6 b7c75870  r7 b7c62120
I/DEBUG   (  431):     r8 99ef38c8  r9 00000000  sl b7c757ec  fp 00000001
I/DEBUG   (  431):     ip 00000000  sp 99ef3798  lr 955fbef9  pc 956afba8  cpsr 200f0030
I/DEBUG   (  431):
I/DEBUG   (  431): backtrace:
I/DEBUG   (  431):     #00 pc 0030cba8  /data/app/com.sambuo.debug-2/lib/arm/libflutter.so
I/DEBUG   (  431):     #01 pc 0030b543  /data/app/com.sambuo.debug-2/lib/arm/libflutter.so
I/DEBUG   (  431):     #02 pc 0030f0d5  /data/app/com.sambuo.debug-2/lib/arm/libflutter.so
I/DEBUG   (  431):     #03 pc 0030fa53  /data/app/com.sambuo.debug-2/lib/arm/libflutter.so
I/DEBUG   (  431):     #04 pc 0009e91d  /data/app/com.sambuo.debug-2/lib/arm/libflutter.so
I/DEBUG   (  431):     #05 pc 0009d855  /data/app/com.sambuo.debug-2/lib/arm/libflutter.so
I/DEBUG   (  431):     #06 pc 0009d80f  /data/app/com.sambuo.debug-2/lib/arm/libflutter.so
I/DEBUG   (  431):     #07 pc 004397ed  /data/app/com.sambuo.debug-2/lib/arm/libflutter.so
I/DEBUG   (  431):     #08 pc 00000714  <unknown>
E/WifiStateMachine( 1028): WifiStateMachine CMD_START_SCAN source -2 txSuccessRate=10.20 rxSuccessRate=14.46 targetRoamBSSID=any RSSI=-53
D/wpa_supplicant( 1577): wlan0: Control interface command 'SIGNAL_POLL'
I/DEBUG   (  431):
I/DEBUG   (  431): Tombstone written to: /data/tombstones/tombstone_09
W/ActivityManager( 1028): Process com.sambuo.debug has crashed too many times: killing!

我已经能够在一个新的 Android 项目中使用它,但我认为我现有的 Android 项目中可能有一些东西影响了构建。

最佳答案

你可能想看看文章 Embedding Flutter in existing Android project在 Arnold Parge 的 Medium 中。

它详细解释了如何调整 build.gradle、AndroidManifest.xml、MainActivity.java 和其他 android 文件。

关于android - Flutter 与现有应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50822134/

相关文章:

flutter - 排除某些文件/库以在Flutter Web中构建

testing - Flutter - 如何在小部件测试中获取文本小部件

php - 在android中使用php将图像上传到mySQL服务器

android - 将位置绑定(bind)到 MVVM 中的 MapView

android - Raspberry Pi 中 Wifi 直连几秒后自动断开连接

flutter - 如何延迟 flutter 中的列表项?

flutter - 屏幕一侧的绿色 strip 有 video_player 抖动

java - getSharedPreferences() 这个抽象方法如何拥有允许其检索信息的主体?

android - 在 onChanged() 回调中解析不同的对象,Livedata

flutter - 新启动时,flutter 应用程序是否会删除写入应用程序文档目录的文件、数据