我正在尝试将Flutter添加到现有的Android应用中,但运行时崩溃了。我正在按照以下步骤操作: https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps。我知道这仍然处于测试阶段,并且在不久的将来可能会变得更好,但是我希望能够帮助其他人,或者我想错过一些简单的东西。
启动FlutterActivity的意图时,活动会启动,但会立即崩溃应用程序。开始活动看起来像这样:
ComponentName componentName = new ComponentName(getActivity(), "com.example.flutterpart.MainActivity");
Intent intent = new Intent().setComponent(componentName);
startActivity(intent);
这是我正在使用的颤动版本:
$ 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项目可能会影响构建。
答案 0 :(得分:1)
您可能需要查看Arnold Parge在Medium中的文章Embedding Flutter in existing Android project。
它详细解释了调整build.gradle,AndroidManifest.xml,MainActivity.java和其他android文件。