最近由于又想重新研究下Flutter
相关技能,由于android studio
升级到了最新版,创建项目默认使用 id 'com.android.library' version '7.2.0' apply false
module依赖参照官方文档进行:
// Include the host app project.
include ':app' // assumed existing content
setBinding(new Binding([gradle: this])) // new
evaluate(new File( // new
settingsDir.parentFile, // new
'my_flutter/.android/include_flutter.groovy' // new
)) // new
在按照官方文档操作之后,报出了如下错误
针对上面的报错,处理方式如下(该处理方式参照自https://github.com/flutter/flutter/issues/99735
):
- step1: 创建
flutter_settings.gradle
文件
setBinding(new Binding([gradle: this]))
evaluate(new File(settingsDir.parentFile, 'flutter_module/.android/include_flutter.groovy'))
- step2: 修改
settings.gradle
文件
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
//repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS) // edit this
repositories {
google()
mavenCentral()
String flutterStorageUrl = System.getenv("FLUTTER_STORAGE_BASE_URL") ?: "https://storage.googleapis.com"
maven {
url flutterStorageUrl + "/download.flutter.io"
}
}
rootProject.name = "FlutterTestModule"
include ':app'
apply { from("flutter_settings.gradle") } // add this
然后重新build运行,就可以看到正常的效果了。