简体   繁体   中英

Flutter crashing with an existing app

I'm trying to add Flutter to an existing Android app, but having runtime crashes. I'm following these steps: https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps . I understand this is still in beta and will probably get better in the near future, but I'm putting this up hoping to help someone else out, or in case there's something simple I missed.

When starting the intent to my FlutterActivity, the activity is launched, but then immediately crashes the app. Starting the activity looks like this:

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

This is the version of flutter I'm using:

$ 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

Here is the crash logs. This has been modified for security and to make it brief, so it's possible I left something important out:

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!

I've been able to get this working with a new Android project, but I think there may be something in my existing Android project affecting the build.

You may want to give a look to the article Embedding Flutter in existing Android project in Medium by Arnold Parge.

It gives detailed explanations to tweak build.gradle, AndroidManifest.xml, MainActivity.java, and other android files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM