Android开发

Android release调用Flutter崩溃

本文主要是介绍Android release调用Flutter崩溃,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

问题

Flutter混合开发Android debug正常, Android release调用Flutter崩溃问题

2021-11-26 22:17:35.057 9897-9897/com.jjmc.esurgerytest E/flutter: [ERROR:flutter/runtime/dart_vm_data.cc(18)] VM snapshot invalid and could not be inferred from settings.
2021-11-26 22:17:35.057 9897-9897/com.jjmc.esurgerytest E/flutter: [ERROR:flutter/runtime/dart_vm.cc(256)] Could not set up VM data to bootstrap the VM from.
2021-11-26 22:17:35.057 9897-9897/com.jjmc.esurgerytest E/flutter: [ERROR:flutter/runtime/dart_vm_lifecycle.cc(84)] Could not create Dart VM instance.
2021-11-26 22:17:35.057 9897-9897/com.jjmc.esurgerytest A/flutter: [FATAL:flutter/shell/common/shell.cc(143)] Check failed: vm. Must be able to initialize the VM.

解决方案

项目配置了 debuggable 为true 为了方便release环境也能 看到日志,由于flutter release不支持热重载,其判断可能是使用 debuggable 以为 当前需要支持热更新,去调用资源造成崩溃 

release.apk > assets release包不存在 flutter相关 asset资源

 debug.apk > assets

 最终处理,删除  app build.gradle 下 

android {

        buildtypes{

        release {
                ... 
            debuggable APP_LOG_DEBUG.toBoolean()  //删除这句即可
       }

        }

}

重新打包release 可以正常运行

这篇关于Android release调用Flutter崩溃的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!