【发布时间】:2022-08-04 14:43:32
【问题描述】:
我刚刚更新了我的颤振项目包以符合空安全性,现在 Android Studio 希望我更新我的项目以使用最新版本的 Kotling Gradle 插件。看不到在哪里改变它。我试图将\"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version\" 更改为\"org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10\" 但这没有效果。
我的build.grade-文件如下所示:
def localProperties = new Properties()
def localPropertiesFile = rootProject.file(\'local.properties\')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader(\'UTF-8\') { reader ->
localProperties.load(reader)
}
}
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.\")
}
def flutterVersionCode = localProperties.getProperty(\'flutter.versionCode\')
if (flutterVersionCode == null) {
flutterVersionCode = \'1\'
}
def flutterVersionName = localProperties.getProperty(\'flutter.versionName\')
if (flutterVersionName == null) {
flutterVersionName = \'1.0\'
}
apply plugin: \'com.android.application\'
apply plugin: \'kotlin-android\'
apply from: \"$flutterRoot/packages/flutter_tools/gradle/flutter.gradle\"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file(\'key.properties\')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 31
sourceSets {
main.java.srcDirs += \'src/main/kotlin\'
}
lintOptions {
disable \'InvalidPackage\'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId \"*********\"
minSdkVersion 30
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner \"androidx.test.runner.AndroidJUnitRunner\"
}
signingConfigs {
release {
keyAlias keystoreProperties[\'keyAlias\']
keyPassword keystoreProperties[\'keyPassword\']
storeFile keystoreProperties[\'storeFile\'] ? file(keystoreProperties[\'storeFile\']) : null
storePassword keystoreProperties[\'storePassword\']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
flutter {
source \'../..\'
}
dependencies {
implementation \"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version\"
testImplementation \'junit:junit:4.12\'
androidTestImplementation \'androidx.test:runner:1.1.1\'
androidTestImplementation \'androidx.test.espresso:espresso-core:3.1.1\'
implementation \'com.google.firebase:firebase-analytics:17.2.2\'
}
apply plugin: \'com.google.gms.google-services\'
构建输出:
BUILD FAILED in 8s
[!] Your project requires a newer version of the Kotlin Gradle plugin.
Find the latest version on https://kotlinlang.org/docs/gradle.html#plugin-and-versions, then update project/android/build.gradle:
ext.kotlin_version = \'<latest-version>\'
Exception: Gradle task assembleDebug failed with exit code 1
标签: flutter android-studio kotlin gradle-kotlin-dsl