開發(fā)語言:Java
開發(fā)生態(tài):Flutter
首先在項(xiàng)目文件下的local.properties文件中,添加如下代碼:
// Flutter SDK的路徑
flutter.sdk=xxx/Flutter/flutter_x.x.x
在插件android目錄的build.gradle文件中,添加如下代碼:
/*此處僅處理因插件項(xiàng)目內(nèi)報紅顯示的處理方式 start*/
//獲取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.")
}
/*此處僅處理因插件項(xiàng)目內(nèi)報紅顯示的處理方式 end*/
dependencies {
//此處僅處理因插件項(xiàng)目內(nèi)報紅顯示的處理方式
compileOnly files("$flutterRoot/bin/cache/artifacts/engine/android-arm/flutter.jar")
compileOnly 'androidx.annotation:annotation:1.2.0'
}
小白的進(jìn)階之路,感謝大家的支持!