問(wèn)題:我在試著新建一個(gè)flutter插件項(xiàng)目后,去寫(xiě)android代碼時(shí)發(fā)現(xiàn)找不到flutter相關(guān)的類(lèi)

去依賴?yán)锟纯创_實(shí)沒(méi)有

后來(lái)各種百度,Google終于找到了解決方案,原來(lái)是新建項(xiàng)目沒(méi)有默認(rèn)把到依賴進(jìn)去
分兩步:
1.local.properties文件里配置flutter_sdk

2.build.gradle文件里添加依賴庫(kù)

//獲取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'
}