The company has already started cross-platform development with Flutter in its projects and has already launched one of its apps. The process has not been too tortuous, following the tutorials on Flutter’s website, including inheritance, packaging, testing and release.
Recently, another project had a new requirement and also started to use Flutter. There was a problem with the integration packaging:
A/flutter: [FATAL:flutter/shell/common/shell.cc(218)] Check failed: vm. Must be able to initialize the VM.
The error logs are as follows:
E/CrashReport: #++++++++++Record By Bugly++++++++++# E/CrashReport: # You can use Bugly(http:\\bugly.qq.com) to get more Crash Detail! E/CrashReport: # PKG NAME: me.chunyu.chunyudoctor E/CrashReport: # APP VER: 8.6.0e /CrashReport: # LAUNCH TIME: 2019-06-19 18:00:12 E/CrashReport: # CRASH TYPE: NATIVE_CRASH E/CrashReport: # CRASH TIME: 2019-06-19 18:00:22 E/CrashReport: # CRASH PROCESS: me.chunyu.ChunyuDoctor E/CrashReport: # CRASH THREAD: main(2) E/CrashReport: # REPORT ID: d88b5d1a-cbb0-4920-b41c-d8ea8eb804bd E/CrashReport: # CRASH DEVICE: MI 5 UNROOT E/CrashReport: # RUNTIME AVAIL RAM:1411100672 ROM:11107233792 SD:11107233792 E/CrashReport: # RUNTIME TOTAL RAM:2824822784 ROM:26300211200 SD:26300211200 E/CrashReport: # EXCEPTION FIRED BY UNKNOWN_USER me.chunyu.ChunyuDoctor(27335) E/CrashReport: # CRASH STACK: E/CrashReport: SIGABRT 0x6ac7 #00 pc 0004b10c /system/lib/libc.so (tgkill+12) [armeabi-v7a::d7f479b7abcbff3bc09ca6d100c44333] #01 pc 0001a9a3 /system/lib/libc.so (abort+54) [armeabi-v7a::d7f479b7abcbff3bc09ca6d100c44333] #02 pc 00af85ab /data/app/me.chunyu.ChunyuDoctor-n6cyA4a8iSyIl6wZ_2ghlw==/lib/arm/libflutter.so [armeabi-v7a::a12434e0b53806a35730000001000000] #03 pc 00b197cf /data/app/me.chunyu.ChunyuDoctor-n6cyA4a8iSyIl6wZ_2ghlw==/lib/arm/libflutter.so [armeabi-v7a::a12434e0b53806a35730000001000000] #04 pc 00aeaf45 /data/app/me.chunyu.ChunyuDoctor-n6cyA4a8iSyIl6wZ_2ghlw==/lib/arm/libflutter.so [armeabi-v7a::a12434e0b53806a35730000001000000] #05 pc 00af0507 /data/app/me.chunyu.ChunyuDoctor-n6cyA4a8iSyIl6wZ_2ghlw==/lib/arm/libflutter.so [armeabi-v7a::a12434e0b53806a35730000001000000] #06 pc 00aef79b /data/app/me.chunyu.ChunyuDoctor-n6cyA4a8iSyIl6wZ_2ghlw==/lib/arm/libflutter.so [armeabi-v7a::a12434e0b53806a35730000001000000] #07 pc 003d9d29 /system/lib/libart.so (ExecuteMterpImpl+37417) [armeabi-v7a::d2078ba50169919802b98e67fdc80c58] #08 pc 003d5fe1 /system/lib/libart.so (ExecuteMterpImpl+21729) [armeabi-v7a::d2078ba50169919802b98e67fdc80c58] #09 pc 003da555 /system/lib/libart.so (art_quick_invoke_stub+228) [armeabi-v7a::d2078ba50169919802b98e67fdc80c58] #10 pc 000a0e1d /system/lib/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+140) [armeabi-v7a::d2078ba50169919802b98e67fdc80c58] #11 pc 001e6e53 /system/lib/libart.so (_ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPKNS_7DexFile8CodeItemEPNS_11Shadow FrameEPNS_6JValueE+238) [armeabi-v7a::d2078ba50169919802b98e67fdc80c58] #12 pc 001e2403 /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+57 4) [armeabi-v7a::d2078ba50169919802b98e67fdc80c58] #13 pc 003c0d75 /system/lib/libart.so (MterpInvokeDirect+360) [armeabi-v7a::d2078ba50169919802b98e67fdc80c58] #14 pc 003c8394 /system/lib/libart.so (artInvokeSuperTrampolineWithAccessCheck+3599) [armeabi-v7a::d2078ba50169919802b98e67fdc80c58] #15 pc 001c9985 /system/lib/libart.so (_ZN3art22IndirectReferenceTable10VisitRootsEPNS_11RootVisitorERKNS_8RootInfoE+16) [armeabi-v7a::d2078ba50169919802b98e67fdc80c58] #16 pc 001ced07 /system/lib/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValu eE+142) [armeabi-v7a::d2078ba50169919802b98e67fdc80c58] #17 pc 001e23ed /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+55 2) [armeabi-v7a::d2078ba50169919802b98e67fdc80c58] #18 pc 003bfebf /system/lib/libart.so (MterpInvokeVirtual+446) [armeabi-v7a::d2078ba50169919802b98e67fdc80c58] #19 pc 003c8294 /system/lib/libart.so (artInvokeSuperTrampolineWithAccessCheck+3343) [armeabi-v7a::d2078ba50169919802b98e67fdc80c58] #20 pc 001c9985 /system/lib/libart.so (_ZN3art22IndirectReferenceTable10VisitRootsEPNS_11RootVisitorERKNS_8RootInfoE+16) [armeabi-v7a::d2078ba50169919802b98e67fdc80c58] #21 pc 001ced07 /system/lib/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValu eE+142) [armeabi-v7a::d2078ba50169919802b98e67fdc80c58] #22 pc 001e23ed /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+55 2) [armeabi-v7a::d2078ba50169919802b98e67fdc80c58] #23 pc 003c0d75 /system/lib/libart.so (MterpInvokeDirect+360) [armeabi-v7a::d2078ba50169919802b98e67fdc80c58] #24 pc 003c8394 /system/lib/libart.so (artInvokeSuperTrampolineWithAccessCheck+3599) [armeabi-v7a::d2078ba50169919802b98e67fdc80c58] #25 pc 001c9985 /system/lib/libart.so (_ZN3art22IndirectReferenceTable10VisitRootsEPNS_11RootVisitorERKNS_8RootInfoE+16) [armeabi-v7a:: E/CrashReport: #++++++++++++++++++++++++++++++++++++++++++#Copy the code
At first I thought there was a problem with the SO package, but the use of so is no different from the app that has been released. Eliminate the effects of this problem. Flutter_assets is missing from the installation package. Untie the installation package and find the same phenomenon. Due to the problem of multi-channel packaging, Flutter_assets were not packaged.
Flutter Issues# 27027 github.com/flutter/flu… Have mentioned this, need in fluuter module build. Gradle (flutter module/android/flutter/build gradle) configured in the same channel information.
Complete configuration package installation run or package above the error. According to the above articles, find flutter under the installation directory of packaging used gradle, flutter/packages/flutter_tools/gradle/flutter gradle file, there is such a method
private void addFlutterTask(Project project)
Which defines tasks for merging resources: Task mergeAssets = project.tasks.findByPath(“:${mainModuleName}:merge${variant.name.capitalize()}Assets”)
The default variable mainModuleName is app, but if the main module of our project is not named with this name, the task will not be executed.
With the print log, mergeAssets is null, resulting in the resource file will not be packaged.
Someone found this problem and submitted a Pull request at github.com/flutter/flu…
The solution is to specify the name of the main module in our project’s setting.gradle file
setBinding(new Binding([gradle: this, mainModuleName: 'example']))
Regarding the problem with multi-channel packaging above, some people said that the android folder in the Flutter Module is generated by Flutter itself and does not commit any content in this folder when submitting code. We can modify the flutter. Gradle file mentioned above to upload the current channel information to the multichannel package, and read the channel information in the Gradle file.
The name of the merge resource task generated by AS should be mentioned here: Such as the current channel is normal, the main project name is example, the generated task is exampleMergeNormalDebugAssets and exampleMergeNormalReleaseAssets. Open gradle Task preview in AS and find the Task in the Task–> Other group of the Module flutter.
String flavor = "" try{ String tempFlavor = project.rootProject.ext.app.flavor if(tempFlavor! =null && ! tempFlavor.empty){ flavor = tempFlavor } } catch (Exception e){ println e } Task mergeAssets if(flavor! =null && ! flavor.empty){ mergeAssets = project.tasks.findByPath(":${mainModuleName}:merge${flavor.capitalize()}${variant.name.capitalize()}Assets") }else{ mergeAssets = project.tasks.findByPath(":${mainModuleName}:merge${variant.name.capitalize()}Assets") }Copy the code
That’s all the content of this article, ask for three consecutive (attention + like + favorites), Ollie!
Recommended reading
-
Juejin. Cn/post / 685898…
-
Juejin. Cn/post / 685743…
-
Juejin. Cn/post / 685636…