Flutter新建插件项目Android里找不到包的问题解决方案
问题:我在试着新建一个flutter插件项目后,去写android代码时发现找不到flutter相关的类

去依赖里看看确实没有

后来各种百度,Google终于找到了解决方案,原来是新建项目没有默认把到依赖进去
分两步:
1.local.properties文件里配置flutter_sdk

2.build.gradle文件里添加依赖库

//获取local.properties配置文件
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 {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
compileOnly files("$flutterRoot/bin/cache/artifacts/engine/android-arm/flutter.jar")
compileOnly 'androidx.annotation:annotation:1.1.0'
}