因此,在我的项目中,Gradle不断地将我的Android作曲库(具体地说:‘androidx.active:active-compose’)推广到最新的1.8.0-alpha05版本.然而,这个版本需要compileSdk 34
才能运行,而Gradle版本8.0.2似乎不支持它.
我的应用程序是build.gradle
:
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id("com.google.dagger.hilt.android")
id("com.google.devtools.ksp")
id 'org.jetbrains.kotlin.plugin.serialization' version '1.8.20'
id 'com.google.gms.google-services'
}
android {
namespace 'com.my_app'
compileSdk 33
defaultConfig {
applicationId "com.my_app"
minSdk 21
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
}
}
applicationVariants.all { variant ->
variant.addJavaSourceFoldersToModel(
new File(buildDir, "generated/ksp/${variant.name}/kotlin")
)
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_18
targetCompatibility JavaVersion.VERSION_18
}
kotlinOptions {
jvmTarget = '18'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.4.6'
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
dependencies {
def exoPlayerVersion = "1.0.2"
def room_version = "2.5.1"
def composeBom = platform('androidx.compose:compose-bom:2023.05.01')
implementation composeBom
androidTestImplementation composeBom
implementation 'androidx.core:core-ktx:1.10.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.6.1")
implementation 'androidx.activity:activity-compose:1.7.2' // <-- the culprit
implementation "androidx.compose.animation:animation-graphics"
implementation 'androidx.compose.ui:ui'
implementation 'androidx.compose.ui:ui-graphics'
implementation 'androidx.compose.ui:ui-tooling-preview'
implementation 'androidx.compose.material3:material3'
implementation 'androidx.compose.foundation:foundation'
implementation 'com.google.android.material:material:1.10.0-alpha04'
implementation('org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1')
// ... Other dependencies
}
投掷./gradlew checkDebugAarMetadata
次:
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> 3 issues were found when checking AAR metadata:
1. Dependency 'androidx.activity:activity-compose:1.8.0-alpha05' requires libraries and applications that
depend on it to compile against version 34 or later of the
Android APIs.
:app is currently compiled against android-33.
Also, the maximum recommended compile SDK version for Android Gradle
plugin 8.0.2 is 33. // <-- this
2. Dependency 'androidx.activity:activity-ktx:1.8.0-alpha05' requires libraries and applications that
depend on it to compile against version 34 or later of the
Android APIs.
// same comment above
3. Dependency 'androidx.activity:activity:1.8.0-alpha05' requires libraries and applications that
depend on it to compile against version 34 or later of the
Android APIs.
// same comment above
我try 使用Gradle的解析策略,但似乎不起作用:
configurations.all {
resolutionStrategy {
force 'androidx.activity:activity-compose:1.7.2'
}
}