1.问题:最近要使用Flutter插件,但是AS的尿性,插件模块自带的xxxxPlugin.kt打开后就报红,出现无法识别flutter中带的各种类,使用Android模式打开也是如此。 2.解决如下: (1)在local.properties文件中添加你的flutter sdk目录:
flutter.sdk=F:\\flutter\\flutter
(2)在build.gradle文件中添加:
//最外层
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
//获取flutter的sdk路径
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
//dependencies 中
compileOnly files("$flutterRoot/bin/cache/artifacts/engine/android-arm/flutter.jar")
compileOnly 'androidx.annotation:annotation:1.1.0'
(3)syn gradle
|