首先Android工程文件要和flutter在同级目录;
1)创建flutter module
flutter create -t module flutter_m
2)在Android项目的 setting_gradle 里面添加
setBinding(new Binding([gradle: this, mainModuleName: '安卓工程名']))
evaluate(new File(
settingsDir.parentFile,
'flutter_m/.android/include_flutter.groovy'
))
flutter_m是flutter工程名
点击右上角***sync***按钮
3)在 app modul 中 build.gradle 中添加设置,添加依赖
android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
implementation project(path: ':flutter')