如何将Dart/Flutter编译为Android? [英] How does Dart/Flutter get compiled to Android?

查看:116
本文介绍了如何将Dart/Flutter编译为Android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到任何具体的资源,Dart是否已编译为JVM,或者Google的团队是否将Dart VM编译为在JVM上运行,然后在JVM的Dart VM中运行Dart?

I can't find any concrete resources on this, does Dart get compiled to JVM, or did the Google's team compile the Dart VM to be run on the JVM and then run Dart inside Dart VM inside JVM?

前者更有意义,并且与没有桥梁"的口头禅相呼应,但后者似乎与

The former makes more sense and it goes inline with the "no bridge" mantra, but the latter seems more inline with how integration between native & flutter code looks like

推荐答案

Dart被编译为本机代码(ARM,Intel等)可执行文件,并与某些本机平台代码(Java,Kotlin,Objective-C/Swift)与本机平台进行交互.

Dart is compiled to native machine code (ARM, Intel, ...) executable and bundled with some native platform code (Java, Kotlin, Objective-C/Swift) to interact with the native platform.

另请参见

Flutter如何在Android上运行我的代码?引擎的C和C ++代码

是使用Android的NDK编译的.Dart代码(SDK和您的)被提前(AOT)编译到本地的ARM库中.该库包含在运行程序" Android项目中,整个库东西内置在APK中.启动后,该应用会加载Flutter图书馆.任何呈现,输入或事件处理等都是委托给已编译的Flutter和应用程序代码.这类似于许多游戏引擎的工作方式.

How does Flutter run my code on Android? The engine’s C and C++ code

are compiled with Android’s NDK. The Dart code (both the SDK’s and yours) are ahead-of-time (AOT) compiled into a native, ARM library. That library is included in a "runner" Android project, and the whole thing is built into an APK. When launched, the app loads the Flutter library. Any rendering, input or event handling, and so on, are delegated to the compiled Flutter and app code. This is similar to the way many game engines work.

调试模式构建使用虚拟机(VM)运行Dart代码(因此他们显示的调试"横幅提醒人们较慢)以启用有状态的热重装.

Debug mode builds use a virtual machine (VM) to run Dart code (hence the "debug" banner they show to remind people that they’re slightly slower) in order to enable stateful hot reload.

与LLVM一起编译.Dart代码(包括SDK和您的)都是提前(AOT)编译到本地ARM库中.那个图书馆包含在一个运行程序" iOS项目中,并且整个过程都已构建.ipa.启动后,该应用程序将加载Flutter库.任何呈现,输入或事件处理等,都委托给编译Flutter和应用程序代码.这类似于许多游戏的方式引擎正常工作.

compiled with LLVM. The Dart code (both the SDK’s and yours) are ahead-of-time (AOT) compiled into a native, ARM library. That library is included in a "runner" iOS project, and the whole thing is built into an .ipa. When launched, the app loads the Flutter library. Any rendering, input or event handling, and so on, are delegated to the compiled Flutter and app code. This is similar to the way many game engines work.

调试模式版本使用虚拟机(VM)运行Dart代码(因此他们显示的调试"标语提醒人们较慢)以启用有状态的热重装.

Debug mode builds use a virtual machine (VM) to run Dart code (hence the "debug" banner they show to remind people that they’re slightly slower) in order to enable stateful hot reload.

https://flutter.io/docs/resources/faq#how-does-flutter-run-my-code-on-android

另请参见 https://proandroiddev.com/flutters-compilation-patterns-24e139d14177

这篇关于如何将Dart/Flutter编译为Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆