Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash App when add flutter module to existing apps #19818

Closed
haihai111 opened this Issue Jul 26, 2018 · 25 comments

Comments

Projects
@haihai111
Copy link

haihai111 commented Jul 26, 2018

Hi everyone,i have a big problem i can't figure out.I have crash when i add flutter module to existing apps.I do follow this link https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps .It's working but when i add fabric.io to build.gradle of android project i have crash.

Steps to Reproduce

  1. do follow https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps it's working
  2. add fabric.io into build.gradle to android project
buildscript {
      repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
    mavenCentral()
}

implementation('com.crashlytics.sdk.android:crashlytics:2.9.4@aar') {
        transitive = true;
}
  1. Build again and app crash.Flutter log error like this

07-26 22:07:19.384 16435-16435/com.app.myapplication E/flutter: [ERROR:flutter/runtime/dart_vm.cc(256)] VM snapshot must be valid.
07-26 22:07:19.384 16435-16435/com.app.myapplication A/flutter: [FATAL:flutter/shell/common/shell.cc(216)] Check failed: vm. Must be able to initialize the VM.

screen shot 2018-07-26 at 10 07 37 pm

Logs

[07-26 22:07:19.384 16435-16435/com.app.myapplication E/flutter: [ERROR:flutter/runtime/dart_vm.cc(256)] VM snapshot must be valid.
07-26 22:07:19.384 16435-16435/com.app.myapplication A/flutter: [FATAL:flutter/shell/common/shell.cc(216)] Check failed: vm. Must be able to initialize the VM.
    
    
    --------- beginning of crash
07-26 22:07:19.384 16435-16435/com.app.myapplication A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 16435 (p.myapplication)
07-26 22:07:19.405 16485-16485/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
07-26 22:07:19.406 16485-16485/? A/DEBUG: Build fingerprint: 'google/sdk_gphone_x86/generic_x86:8.0.0/OSR1.170901.043/4456315:user/release-keys'
    Revision: '0'
07-26 22:07:19.407 16485-16485/? A/DEBUG: ABI: 'x86'
    pid: 16435, tid: 16435, name: p.myapplication  >>> com.app.myapplication <<<
    signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
07-26 22:07:19.409 16485-16485/? A/DEBUG: Abort message: '[FATAL:flutter/shell/common/shell.cc(216)] Check failed: vm. Must be able to initialize the VM.
    '
        eax 00000000  ebx 00004033  ecx 00004033  edx 00000006
        esi 00004033  edi bffaada8
        xcs 00000073  xds 0000007b  xes 0000007b  xfs 0000003b  xss 0000007b
        eip acb6aac4  ebp bffaadc8  esp bffaad5c  flags 00200296
07-26 22:07:19.411 16485-16485/? A/DEBUG: backtrace:
        #00 pc 00000ac4  [vdso:acb6a000] (__kernel_vsyscall+16)
        #01 pc 00075b3c  /system/lib/libc.so (tgkill+28)
        #02 pc 0001f04e  /system/lib/libc.so (abort+110)
        #03 pc 00334383  /data/app/com.app.myapplication-Vn-1qYse4nMlk8AyJbFuPQ==/lib/x86/libflutter.so
        #04 pc 00334ab9  /data/app/com.app.myapplication-Vn-1qYse4nMlk8AyJbFuPQ==/lib/x86/libflutter.so
        #05 pc 000d1b4f  /data/app/com.app.myapplication-Vn-1qYse4nMlk8AyJbFuPQ==/lib/x86/libflutter.so
        #06 pc 0007cd33  /data/app/com.app.myapplication-Vn-1qYse4nMlk8AyJbFuPQ==/lib/x86/libflutter.so
        #07 pc 00086283  /data/app/com.app.myapplication-Vn-1qYse4nMlk8AyJbFuPQ==/lib/x86/libflutter.so
        #08 pc 0001b43a  /data/app/com.app.myapplication-Vn-1qYse4nMlk8AyJbFuPQ==/oat/x86/base.odex (offset 0x1b000)
        #09 pc 000d9fff  [anon:libc_malloc:a8500000]
        #10 pc 0056e99f  /dev/ashmem/dalvik-main space (region space) (deleted)

@zoechi

This comment has been minimized.

Copy link
Contributor

zoechi commented Jul 26, 2018

Please add the output of flutter doctor -v.

@jason-simmons

This comment has been minimized.

Copy link
Contributor

jason-simmons commented Jul 26, 2018

What do the contents of the APK zip file look like before and after adding the fabric.io dependency?

The assertion failure indicates that the Flutter engine can not find the assets representing the application's Dart code.

Look for files in the APK such as assets/flutter_assets/isolate_snapshot_data, assets/flutter_assets/kernel_blob.bin, assets/flutter_assets/platform.dill, and assets/flutter_assets/vm_snapshot_data.

Are these files still present in the right places after adding fabric.io?

@haihai111

This comment has been minimized.

Copy link
Author

haihai111 commented Jul 27, 2018

this is flutter doctor,everything is fine

screen shot 2018-07-27 at 8 35 20 am

@haihai111

This comment has been minimized.

Copy link
Author

haihai111 commented Jul 27, 2018

@jason-simmons
APK after add fabric have assets flutter such as isolate_snapshot_data,vm_snapshot_data.But when i add fabric,it gone!!!

@haihai111

This comment has been minimized.

Copy link
Author

haihai111 commented Jul 27, 2018

Hi i found reason make app crash.
apply plugin: 'io.fabric'
This is a code make crash app,when i remove it app working.But when i remove that code,i can't install fabric in my app!!!

@matthew-carroll matthew-carroll added this to To do in Add-to-App Aug 20, 2018

@matthew-carroll matthew-carroll moved this from To do to To do (Bugs) in Add-to-App Aug 20, 2018

@loidoan

This comment has been minimized.

Copy link

loidoan commented Aug 23, 2018

I was also so. Is there a way to fix it?

@luanpotter

This comment has been minimized.

Copy link
Contributor

luanpotter commented Aug 24, 2018

I also had the exactly same problem, can confirm that removing the apply plugin from fabric solves the problem, but is there a way to keep using fabric? Is it a problem with the fabric plugin itself?

@ZhangQinglian

This comment has been minimized.

Copy link

ZhangQinglian commented Aug 26, 2018

I had the problem too.Is there some way to solve this problem without remove fabric ?

@loidoan

This comment has been minimized.

Copy link

loidoan commented Aug 27, 2018

Here ! I fixed this. You can checkout Upgrading Flutter channel master "https://flutter.io/upgrading/" . You without remove fabric. When you upgrading after restart your project.

@ZhangQinglian

This comment has been minimized.

Copy link

ZhangQinglian commented Aug 27, 2018

Still not work .

@haihai111

This comment has been minimized.

Copy link
Author

haihai111 commented Aug 27, 2018

add this line in strings.xml
"< string name="com.crashlytics.RequireBuildId">false < /string > "
and remove : apply plugin: 'io.fabric'
in build.gradle
Now fabric still work and when you build release flutter not crash.I don't know why,but it woking.You can try

@loidoan

This comment has been minimized.

Copy link

loidoan commented Aug 27, 2018

@haihai111 thanks you. I can do it. But i don't know why?. I think Fultter add plugin faric ✌️

@ZhangQinglian

This comment has been minimized.

Copy link

ZhangQinglian commented Aug 28, 2018

when the app crash , I find that apk's assets path missing "flutter_shared" .

@matthew-carroll

This comment has been minimized.

Copy link
Contributor

matthew-carroll commented Sep 18, 2018

@mravn did you happen to root cause the Gradle issue here?

@mravn

This comment has been minimized.

Copy link
Contributor

mravn commented Sep 19, 2018

@matthew-carroll Sorry, no.

@matthew-carroll matthew-carroll moved this from To do (Bugs) to External Help in Add-to-App Sep 26, 2018

@sbaranov sbaranov self-assigned this Oct 2, 2018

Add-to-App automation moved this from External Help to Done Oct 9, 2018

@potatoker

This comment has been minimized.

Copy link

potatoker commented Nov 20, 2018

I do not have apply plugin: 'io.fabric' in my gradle but still get this error

@kimlet

This comment has been minimized.

Copy link

kimlet commented Nov 23, 2018

after one day research, finally I find this

image
Go to you_flutter_project/.android
run ./gradlew assembleDebug and generate flutter-debug.aar it contains flutter_assets folder

but

run ./gradlew flutter:assembleDebug does not contains flutter_assets folder

@potatoker

This comment has been minimized.

Copy link

potatoker commented Nov 24, 2018

hi, all, In my situation, I pulled my flutter module from git repository.
I run flutter clean and flutter run then everything is ok

@kimlet

This comment has been minimized.

Copy link

kimlet commented Nov 26, 2018

hi, all, In my situation, I pulled my flutter module from git repository.
I run flutter clean and flutter run then everything is ok

you can just run gradlew assembleDebug or gradlew assembleRelease

@hnvn

This comment has been minimized.

Copy link

hnvn commented Dec 18, 2018

@kimlet is right. The main reason for E/flutter: [ERROR:flutter/runtime/dart_vm.cc(259)] VM snapshot must be valid. is missing of flutter_assets. For my case, I temporarily get around this matter by doing folowing steps (I use MacOS):

  1. run ./gradlew assemble inside .android.
  2. go to .android/Flutter/build/outputs/aar/, copy a proper aar file (there're some aar file for debug, release and profile), extract it with unzip command and copy flutter_asssets in extracted folder.
  3. create assets folder inside my existing Android project, paste fluter_assets there. Done!

The reason of why flutter doesn't pack flutter_assets to output apk file in my case is still unexplained. It's even more curious when I create a new dummy android project and try to add flutter module to it. It works well. I guess that my real project has some problems in gradle config that causes flutter ignoring flutter_assets

@EchoFUN

This comment has been minimized.

Copy link

EchoFUN commented Dec 21, 2018

@hnvn exactly the same problem here, I have tried your steps, still gone crash, so sad~

@ghalong

This comment has been minimized.

Copy link

ghalong commented Jan 16, 2019

@kimlet is right. The main reason for E/flutter: [ERROR:flutter/runtime/dart_vm.cc(259)] VM snapshot must be valid. is missing of flutter_assets. For my case, I temporarily get around this matter by doing folowing steps (I use MacOS):

  1. run ./gradlew assemble inside .android.
  2. go to .android/Flutter/build/outputs/aar/, copy a proper aar file (there're some aar file for debug, release and profile), extract it with unzip command and copy flutter_asssets in extracted folder.
  3. create assets folder inside my existing Android project, paste fluter_assets there. Done!

The reason of why flutter doesn't pack flutter_assets to output apk file in my case is still unexplained. It's even more curious when I create a new dummy android project and try to add flutter module to it. It works well. I guess that my real project has some problems in gradle config that causes flutter ignoring flutter_assets

Thank you! It does work for me!

@durduman

This comment has been minimized.

Copy link

durduman commented Feb 5, 2019

@hnvn
I tried your steps and they worked for me as well.

I have have question though:
Have you copied your android project into the path <<../my_flutter/> after you created the flutter module? (flutter create -t module my_flutter)
I am asking this because this is one of the more important changes I had done to my setup before I broke the build.
Anyway, thanks a lot for your steps!

@yk3372

This comment has been minimized.

Copy link

yk3372 commented Feb 15, 2019

I find the reason:
if you config Flavor in app, the flutter lib must config the same Flavor.
if not, such as compileDevDebug will not found when build.

so, add the app's Flavor to the Flutter lib module, make the lib has the same compileDevDebug.

@lwb2016

This comment has been minimized.

Copy link

lwb2016 commented Mar 20, 2019

I find the reason:
if you config Flavor in app, the flutter lib must config the same Flavor.
if not, such as compileDevDebug will not found when build.

so, add the app's Flavor to the Flutter lib module, make the lib has the same compileDevDebug.
it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.