Flutter Error: VM snapshot invalid and could not be inferred from settings. – When want to include Flutter module in android project

Issue

Use this Option B in link to include Flutter model.
The project starts, but as soon as it comes to initializing the FlutterEngine, this error is thrown.

2021-12-10 13:54:09.300 12446-12446/ua.silpo.android.mtest E/flutter: [ERROR:flutter/runtime/dart_vm_data.cc(18)] VM snapshot invalid and could not be inferred from settings.
    2021-12-10 13:54:09.300 12446-12446/ua.silpo.android.mtest E/flutter: [ERROR:flutter/runtime/dart_vm.cc(267)] Could not set up VM data to bootstrap the VM from.
    2021-12-10 13:54:09.300 12446-12446/ua.silpo.android.mtest E/flutter: [ERROR:flutter/runtime/dart_vm_lifecycle.cc(84)] Could not create Dart VM instance.
    2021-12-10 13:54:09.300 12446-12446/ua.silpo.android.mtest A/flutter: [FATAL:flutter/shell/common/shell.cc(144)] Check failed: vm. Must be able to initialize the VM.
    2021-12-10 13:54:09.489 12603-12603/? A/DEBUG: Abort message: '[FATAL:flutter/shell/common/shell.cc(144)] Check failed: vm. Must be able to initialize the VM.
        '
    2021-12-10 13:54:09.490 12603-12603/? A/DEBUG:     #01 pc 00000000002cdfd4  /data/app/ua.someApp.android.mtest-MaQO6akxb8zud-dIXl0K7w==/lib/arm64/libflutter.so (offset 0x2c6000)

Solution

The actions are the following and the solution:

  • created Flutter module.

  • used connection to android via Option B.

  • since the project had no name: app,
    i wrote in gradle.properties -> flutter.hostAppProjectName = myAppName

  • my settings.gradle looked like this

    rootProject.name = "mobileAndroid"
    include ‘: app’
    setBinding (new Binding ([gradle: this]))
    evaluate (new File (
    settingsDir.parentFile,
    ‘./SuperApp_Frontend_Silpo/.android/include_flutter.groovy’
    ))

But the problem was that the project had its own buildTypes, so it was necessary to write

staging {
matchingFallbacks = ['debug', 'release']
}

in Flutter module build.gradle

Answered By – greengo

Answer Checked By – David Goodson (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.