我在我的项目中升级了
build.gradle
:
com.android.tools.build:gradle
从版本7.0.4
到8.3.1
org.jetbrains.kotlin:kotlin-gradle-plugin
从版本1.7.0
到1.9.0
这是我的
build.gradle
内容:
buildscript {
ext.detekt_gradle_plugin_version = "1.17.1"
ext.spotbugs_gradle_plugin_version = "4.5.1"
ext.dokka_version = "1.4.32"
ext.hilt_version = "2.42"
ext.kotlinx_version = "1.3.9"
ext.serialization = "1.3.3"
ext.multidex_version = "2.0.1"
ext.constraintlayout_version = '2.0.2'
ext.preference_version = "1.1.1"
ext.retrofit2_version = '2.9.0'
ext.coroutines_adapter_version = "0.9.2"
ext.moshi_adapters_version = '1.11.0'
ext.moshi_kotlin_adapter_version = '1.11.0'
ext.okhttp_logging_version = "4.9.0"
ext.okhttp_idling_resource_version = "1.0.0"
ext.appcompat_version = "1.3.1"
ext.recyclerview_version = "1.2.1"
ext.material_version = "1.4.0"
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
}
}
rootProject.allprojects {
repositories {
google()
mavenCentral()
}
}
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlinx-serialization'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 34
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
namespace("com.example.plugin")
minSdkVersion 21
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
lintOptions {
disable 'InvalidPackage'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
buildTypes {
release {
minifyEnabled true
consumerProguardFiles 'proguard-rules.pro'
}
}
kapt {
javacOptions {
// These options are normally set automatically via the Hilt Gradle plugin, but we
// set them manually to workaround a bug in the Kotlin 1.5.20
option("-Adagger.fastInit=ENABLED")
option("-Adagger.hilt.android.internal.disableAndroidSuperclassValidation=true")
}
}
}
dependencies {
// Dependencies
implementation "com.adyen.checkout:drop-in:5.3.1"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinx_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinx_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$serialization"
implementation "androidx.multidex:multidex:$multidex_version"
implementation "androidx.appcompat:appcompat:$appcompat_version"
implementation "androidx.recyclerview:recyclerview:$recyclerview_version"
implementation "androidx.constraintlayout:constraintlayout:$constraintlayout_version"
implementation "androidx.preference:preference-ktx:$preference_version"
implementation "com.google.android.material:material:$material_version"
implementation "com.squareup.retrofit2:retrofit:$retrofit2_version"
implementation "com.squareup.retrofit2:converter-moshi:$retrofit2_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit2_version"
implementation "com.squareup.moshi:moshi-adapters:$moshi_adapters_version"
implementation "com.squareup.moshi:moshi-kotlin:$moshi_kotlin_adapter_version"
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp_logging_version"
implementation "com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:$coroutines_adapter_version"
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-compiler:$hilt_version"
}
现在我在构建应用程序时遇到此错误:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':example:kaptGenerateStubsDebugKotlin'.
> Error while evaluating property 'filteredArgumentsMap' of task ':example:kaptGenerateStubsDebugKotlin'
> Could not resolve all files for configuration ':example:kotlinCompilerPluginClasspathDebug'.
> Could not find org.jetbrains.kotlin:kotlin-serialization-compiler-plugin-embeddable:1.7.0.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-serialization-compiler-plugin-embeddable/1.7.0/kotlin-serialization-compiler-plugin-embeddable-1.7.0.pom
- https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-serialization-compiler-plugin-embeddable/1.7.0/kotlin-serialization-compiler-plugin-embeddable-1.7.0.pom
- https://storage.googleapis.com/download.flutter.io/org/jetbrains/kotlin/kotlin-serialization-compiler-plugin-embeddable/1.7.0/kotlin-serialization-compiler-plugin-embeddable-1.7.0.pom
Required by:
project :example
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
Error: Gradle task assembleDebug failed with exit code 1
Exited (1).
有人知道如何解决这个问题吗?
看起来发生错误是因为找不到 Kotlin 序列化编译器插件版本 1.7.0。这可能是由于
build.gradle
文件中指定的版本与存储库中的可用版本不匹配造成的。
升级序列化插件版本以匹配 Kotlin 版本。
ext.serialization = "1.9.0"