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 · 29 comments · Fixed by #22707
Closed

Crash App when add flutter module to existing apps #19818

haihai111 opened this issue Jul 26, 2018 · 29 comments · Fixed by #22707
Assignees
Labels
a: existing-apps Integration with existing apps via the add-to-app flow c: crash Stack traces logged to the console

Comments

@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 zoechi added c: crash Stack traces logged to the console a: existing-apps Integration with existing apps via the add-to-app flow labels Jul 26, 2018
@zoechi
Copy link
Contributor

zoechi commented Jul 26, 2018

Please add the output of flutter doctor -v.

@jason-simmons
Copy link
Member

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
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
Copy link
Author

@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
Copy link
Author

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 moved this from To do to To do (Bugs) in Add-to-App (stale) Aug 20, 2018
@loidoan
Copy link

loidoan commented Aug 23, 2018

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

@luanpotter
Copy link
Contributor

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
Copy link

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

@loidoan
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
Copy link

Still not work .

@haihai111
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
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
Copy link

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

@matthew-carroll
Copy link
Contributor

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

@mravn
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 (stale) Sep 26, 2018
@sbaranov sbaranov self-assigned this Oct 2, 2018
Add-to-App (stale) automation moved this from External Help to Done Oct 9, 2018
@potatoker
Copy link

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

@kimlet
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
Copy link

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
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
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
Copy link

EchoFUN commented Dec 21, 2018

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

@ghalong
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
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
Copy link
Contributor

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
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!

@rayliverified
Copy link

@yk3372 thank you so much for this piece of advice. It helped me fix the error and run my Flutter module successfully. For other users experiencing this problem, you have to add the flavors you have in your app to the Flutter plugin's build.grade. It is not necessary to add flavors to the generated .android build.gradle file.
The flavors should only contain the flavor names and not any configurations in order to not conflict with your app's flavor settings.

Example:

    buildTypes {
        release {
        }

        debug {
        }
    }
    flavorDimensions "environment"
    productFlavors {
        dev {
        }
        qa {
        }
        prod {
        }
    }

@Kamil-Kaminski
Copy link

I can confirm that adding empty build types and flavours fixes problem with integrating flutter module into existing application ❤️

@huangbin30744
Copy link

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 helps me thanks a lot

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: existing-apps Integration with existing apps via the add-to-app flow c: crash Stack traces logged to the console
Projects
No open projects
Development

Successfully merging a pull request may close this issue.