新建的flutter项目没有MainActivity.java,只有MainActivity.kt

1,817 阅读1分钟

If you are creating a new flutter app using the latest stable version, the default now is Kotlin for android and Swift for IOS. You can read more here: github.com/flutter/flu…

If you want to create a new app using Java for Android and Objective-C for IOS use the following command:

flutter create -i objc -a java new_app

对于已有项目,如果把/ios和/android文件夹删掉,运行

flutter create -i objc -a java .

会再次生成初始化的/ios 和/android,这里指定了ios使用objective-c,Android用java 如果不加参数直接运行

flutter create .

则会默认ios使用swift,Android使用kotlin

vscode cmd+, 可以进行默认语言的设置

参考:

FlutterからJava/Objective-Cのネイティブコードを呼んでみた

Switch flutter create default to Kotlin and Swift #21190