我更新了我的android工作室到最新版本火烈鸟今天上午后,因为我无法创建一个新的撰写项目,得到下面的错误
No matching variant of com.android.tools.build:gradle:8.0.0 was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.0'
但是:- Variant 'apiElements' capabilitycom.android.tools.build:gradle:8.0.0声明了一个库,打包为jar,其依赖关系对外声明:- 不兼容,因为此组件声明了一个在编译时使用的组件,与Java 11兼容,而消费者需要一个在运行时使用的组件,与Java 8兼容
我的应用级别
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
namespace 'com.abc.myflamingotestapp'
compileSdk 33
defaultConfig {
applicationId "com.abc.myflamingotestapp"
minSdk 24
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.3.2'
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.5.1'
implementation platform('androidx.compose:compose-bom:2022.10.00')
implementation 'androidx.compose.ui:ui'
implementation 'androidx.compose.ui:ui-graphics'
implementation 'androidx.compose.ui:ui-tooling-preview'
implementation 'androidx.compose.material3:material3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation platform('androidx.compose:compose-bom:2022.10.00')
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
debugImplementation 'androidx.compose.ui:ui-tooling'
debugImplementation 'androidx.compose.ui:ui-test-manifest'
}
Gradle Package 器
#Mon Apr 17 20:26:41 IST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
顶级Gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '8.0.0' apply false
id 'com.android.library' version '8.0.0' apply false
id 'org.jetbrains.kotlin.android' version '1.5.31' apply false
}
得到这个问题,而试图建立,如果其他人也面临着同样的问题,请帮助或建议的东西。
2条答案
按热度按时间jjhzyzn01#
由于您使用的是Android API级别33,Java 11 is available through desugaring。
您现在可以将源和目标兼容性更改为Java 11:
slsn1g292#
如果你不想改变与版本11的兼容性而停留在1.8中,你可以将其脱糖:
首先将Gradle更新到8.0.0(至少4.0.0),修改build.gradle.kts:
或修改build.gradle:
如www.example.com所示https://developer.android.com/build/releases/gradle-plugin#updating-plugin
然后,将其删除,修改应用的模块build.gradle.kts文件:
或者build.gradle Groovy文件:
如www.example.com中所示https://developer.android.com/studio/write/java8-support#library-desugaring。
请记住,您需要删除www.example.com文件中jvmargs的 *-XX:MaxPermSize= 1024 m * 参数gradle.properties,以避免错误。