Flutter错误:VM快照无效,无法从设置中推断

时间:2019-06-25 09:22:20

标签: android flutter

将flutter作为模块添加到我现有的项目中,并导致此崩溃。 遵循此link

2019-06-24 11:08:24.366 30834-30834/com.alarmnet.tc2 E/flutter: [ERROR:flutter/runtime/dart_vm_data.cc(19)] VM snapshot invalid and could not be inferred from settings.
2019-06-24 11:08:24.366 30834-30834/com.alarmnet.tc2 E/flutter: [ERROR:flutter/runtime/dart_vm.cc(241)] Could not setup VM data to bootstrap the VM from.
2019-06-24 11:08:24.366 30834-30834/com.alarmnet.tc2 E/flutter: [ERROR:flutter/runtime/dart_vm_lifecycle.cc(89)] Could not create Dart VM instance.
2019-06-24 11:08:24.366 30834-30834/com.alarmnet.tc2 A/flutter: [FATAL:flutter/shell/common/shell.cc(218)] Check failed: vm. Must be able to initialize the VM.
2019-06-24 11:08:24.368 30834-30834/com.alarmnet.tc2 A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 30834 (om.alarmnet.tc2)

2 个答案:

答案 0 :(得分:1)

找到解决方法:

如果您尝试按照此link

向现有项目添加内容,

打开您的Flutter SDK:FlutterSdk / flutter / packages / flutter_tools / gradle / flutter.gradle

  • 在任何编辑器中打开flutter.gradle并进行以下更改

来自:

   // We know that the flutter app is a subproject in another Android app when these tasks exist.
Task packageAssets = project.tasks.findByPath(":flutter:package${variant.name.capitalize()}Assets")
Task cleanPackageAssets = project.tasks.findByPath(":flutter:cleanPackage${variant.name.capitalize()}Assets")
Task copyFlutterAssetsTask = project.tasks.create(name: "copyFlutterAssets${variant.name.capitalize()}", type: Copy) {
dependsOn flutterTasks
if (packageAssets && cleanPackageAssets) {
dependsOn packageAssets
dependsOn cleanPackageAssets
into packageAssets.outputDir
} else {
dependsOn variant.mergeAssets
dependsOn "clean${variant.mergeAssets.name.capitalize()}"
into variant.mergeAssets.outputDir
}
flutterTasks.each { flutterTask ->
with flutterTask.assets
// Include the snapshots in the assets directory.
if (flutterBuildMode != 'release' || targetPlatformValue != 'android-arm-all') {
with flutterTask.snapshots
}
}
}
  if (packageAssets) {
      String mainModuleName = "app"
     try {
               String tmpModuleName = project.rootProject.ext.mainModuleName
               if (tmpModuleName != null && !tmpModuleName.empty) {
            mainModuleName = tmpModuleName
     }
   } catch (Exception e) {
   }
 Only include configurations that exist in parent project.
 Task mergeAssets = project.tasks.findByPath(":${mainModuleName}:merge${variant.name.capitalize()}Assets")
      if (mergeAssets) {
        mergeAssets.dependsOn(copyFlutterAssetsTask)
  }
} else {
  def processResources = variant.outputs.first().processResources
  processResources.dependsOn(copyFlutterAssetsTask)
 }

收件人:

    // We know that the flutter app is a subproject in another Android app when these tasks exist.
Task packageAssets = project.tasks.findByPath(":flutter:package${variant.name.capitalize()}Assets")
Task cleanPackageAssets = project.tasks.findByPath(":flutter:cleanPackage${variant.name.capitalize()}Assets")
Task copyFlutterAssetsTask = project.tasks.create(name: "copyFlutterAssets${variant.name.capitalize()}", type: Copy) {
dependsOn flutterTasks
if (packageAssets && cleanPackageAssets) {
dependsOn packageAssets
dependsOn cleanPackageAssets
into packageAssets.outputDir
} else {
dependsOn variant.mergeAssets
dependsOn "clean${variant.mergeAssets.name.capitalize()}"
into variant.mergeAssets.outputDir
}
flutterTasks.each { flutterTask ->
with flutterTask.assets
// Include the snapshots in the assets directory.
if (flutterBuildMode != 'release' || targetPlatformValue != 'android-arm-all') {
with flutterTask.snapshots
}
}
}
//  if (packageAssets) {
//      String mainModuleName = "app"
//      try {
//               String tmpModuleName = project.rootProject.ext.mainModuleName
//               if (tmpModuleName != null && !tmpModuleName.empty) {
//             mainModuleName = tmpModuleName
//     }
//   } catch (Exception e) {
//   }
// Only include configurations that exist in parent project.
// Task mergeAssets = project.tasks.findByPath(":${mainModuleName}:merge${variant.name.capitalize()}Assets")
//      if (mergeAssets) {
//        mergeAssets.dependsOn(copyFlutterAssetsTask)
//  }
//} else {
//  def processResources = variant.outputs.first().processResources
//  processResources.dependsOn(copyFlutterAssetsTask)
// }
def processResources = variant.outputs.first().processResources
processResources.dependsOn(copyFlutterAssetsTask)

保存并遵循此link

答案 1 :(得分:0)

如果在现有应用程序中添加了flutter,请转到flutter模块-> .android-> build.gradle。 classpath必须与Android相同

dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
    }