我正在做一个项目,今天构建不再工作了。 错误如下:
检查 AAR 元数据时发现 2 个问题:
Dependency 'androidx.core:core:1.12.0-alpha01' 需要库和应用程序 依靠它来编译代号为“UpsideDownCake”的 Android API。
:app 目前是针对 android-33 编译的。
推荐操作:使用不同版本的依赖'androidx.core:core:1.12.0-alpha01', 或者在你的 build.gradle 中将 compileSdkPreview 设置为“UpsideDownCake” 如果您打算试用该预览版 SDK,请提交文件。
Dependency 'androidx.core:core-ktx:1.12.0-alpha01' 需要库和应用程序 依靠它来编译代号为“UpsideDownCake”的 Android API。
:app 目前是针对 android-33 编译的。
推荐操作:使用不同版本的依赖'androidx.core:core-ktx:1.12.0-alpha01', 或者在你的 build.gradle 中将 compileSdkPreview 设置为“UpsideDownCake” 如果您打算试用该预览版 SDK,请提交文件。
根据我的研究,我了解到错误消息中的版本是昨天发布的,根据官方文档。
下面是项目正在使用的build.gradle脚本。 在我的 build.gradle 中,我有
implementation 'androidx.core:core-ktx:1.9.0'
。我不明白为什么在构建阶段添加另一个版本以及为什么添加androidx.core:core:1.12.0-alpha01
.
build.gradle:
buildscript {
apply from: './dependencies.gradle'
repositories {
google()
mavenCentral()
jcenter()
gradlePluginPortal()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.0'
classpath 'com.google.gms:google-services:4.3.14'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin_version"
classpath "com.google.dagger:hilt-android-gradle-plugin:$versions.hilt_android"
}
}
allprojects {
repositories {
google()
mavenCentral()
jcenter()
maven { url "https://maven.google.com" }
maven { url 'https://jitpack.io' }
maven { url = "https://jcenter.bintray.com" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
dependencies.gradle:
ext.versions = [
minSdkLib : 23,
compileSdk : 33,
versionCode : 8,
versionName : '1.0.8',
kotlin_version : '1.8.0',
hilt_android : '2.44',
hilt_compiler : '2.44',
]
build.gradle(应用程序):
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-parcelize'
id 'com.google.gms.google-services'
id 'com.google.firebase.crashlytics'
id 'dagger.hilt.android.plugin'
id 'org.jetbrains.kotlin.android'
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}
apply from: '../dependencies.gradle'
android {
compileSdkVersion versions.compileSdk
buildToolsVersion "30.0.3"
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
buildFeatures {
dataBinding = true
// For view binding:
viewBinding true
}
defaultConfig {
applicationId "***"
minSdkVersion versions.minSdkLib
targetSdkVersion versions.compileSdk
versionCode versions.versionCode
versionName versions.versionName
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.debug
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
debuggable false
}
debug {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '11'
}
packagingOptions {
exclude 'META-INF/proguard/androidx-annotations.pro'
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.6.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
implementation 'androidx.annotation:annotation:1.5.0'
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1"
implementation "androidx.lifecycle:lifecycle-common-java8:2.5.1"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.1"
/* Work */
implementation 'androidx.work:work-runtime:2.7.1'
implementation 'com.google.android.material:material:1.8.0'
// Added Dependencies
implementation "androidx.recyclerview:recyclerview:1.2.1"
//
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation 'androidx.activity:activity-ktx:1.6.1'
implementation("io.coil-kt:coil:1.2.0")
/* Android 6.0 (Marshmallow) permission */
implementation 'com.karumi:dexter:6.2.3'
/* This is a logger with a small, extensible API which provides
utility on top of Android's normal Log class. */
implementation 'com.jakewharton.timber:timber:4.7.1'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation "com.squareup.okhttp3:okhttp:4.10.0"
implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0'
implementation "com.squareup.retrofit2:converter-moshi:2.9.0"
implementation "com.squareup.moshi:moshi-kotlin:1.14.0"
implementation 'com.squareup.moshi:moshi:1.14.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
kapt 'com.squareup.moshi:moshi-kotlin-codegen:1.14.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
// Dagger Hilt
implementation "com.google.dagger:hilt-android:$versions.hilt_android"
implementation 'org.chromium.net:cronet-embedded:108.5359.79'
kapt "com.google.dagger:hilt-android-compiler:$versions.hilt_compiler"
kapt 'androidx.hilt:hilt-compiler:1.0.0'
// Paging
implementation "androidx.paging:paging-runtime-ktx:3.1.1"
/* Kotlin coroutines */
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1"
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.3.2")
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.0'
/* ssp for text size for all multiple devices */
implementation 'com.intuit.ssp:ssp-android:1.0.6'
/* sdp for all multiple devices size */
implementation 'com.intuit.sdp:sdp-android:1.0.6'
/* Image picker and Camera */
implementation 'com.github.dhaval2404:imagepicker-support:1.7.1'
/* Crash reporter in debug builds only */
debugImplementation 'com.balsikandar.android:crashreporter:1.1.0'
// Biometric
implementation 'androidx.biometric:biometric:1.1.0'
// FCM
implementation platform('com.google.firebase:firebase-bom:31.0.2')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-crashlytics-ktx'
implementation 'com.google.firebase:firebase-messaging-ktx'
// Calendar
implementation 'com.applandeo:material-calendar-view:1.8.0-rc01'
// Horizontal Calendar
implementation 'devs.mulham.horizontalcalendar:horizontalcalendar:1.3.4'
// Stripe SDK
implementation 'com.stripe:stripe-android:20.16.1'
// Testing libraries
testImplementation 'junit:junit:4.13.2'
testImplementation "com.google.truth:truth:1.1.3"
androidTestImplementation "com.google.truth:truth:1.1.3"
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation "androidx.test:core-ktx:1.5.0"
debugImplementation 'androidx.fragment:fragment-testing:1.5.5'
//
implementation 'de.hdodenhof:circleimageview:3.1.0'
/// Zoom image
implementation 'com.jsibbold:zoomage:1.3.1'
/// S: Glide
implementation 'com.github.bumptech.glide:glide:4.12.0'
kapt 'com.github.bumptech.glide:compiler:4.12.0'
// Bar
implementation 'com.github.hadiidbouk:ChartProgressBar-Android:2.0.6'
// One Signal
implementation 'com.onesignal:OneSignal:[4.0.0, 4.99.99]'
// Color picker
implementation 'com.github.yukuku:ambilwarna:2.0.1'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.6.1'
implementation group: 'com.squareup.retrofit2', name: 'adapter-rxjava2', version: '2.6.1'
// Toast
implementation 'com.github.ahmmedrejowan.CuteToast:CuteToast:1.2'
}
我今天有同样的错误,这就是为我修复它的方法:在build.gradle
文件中检查
所有库模块以进行此导入(您可以在Android Studio中搜索Edit→Find → 在文件中查找... 菜单选项):
implementation 'androidx.core:core-ktx:+'
更换最新的稳定版,避免报错:
implementation 'androidx.core:core-ktx:1.9.0'
同步您的项目,错误应该消失了!
我有同样的问题,但我的项目没有这个generic依赖:
androidx.core:core-ktx:+
但是 我的一些依赖项具有它(您可以使用 Gradle“依赖项分析器”查看它)。所以你需要告诉 Gradle 为你的依赖强制一个特定的依赖版本:
configurations.all {
resolutionStrategy {
force("androidx.core:core-ktx:1.9.0")
}
}
我有同样的问题。添加这一行;它与Android 14变化有关:
defaultConfig {
compileSdkPreview = "UpsideDownCake"
}
我有同样的问题。
这有帮助:
defaultConfig {
compileSdkPreview = "UpsideDownCake"
}
但是它在创建 APK 文件/包时产生了一个问题,所以对我来说最好的解决方案是降级 Gradle。
Android Gradle 插件版本 7.1.1 || Gradle 版本 7.3
就像 Aleksandr Zurnachyan 说的。 我面临同样的问题。
推荐操作:使用不同版本的依赖项“androidx.core:core:1.12.0-alpha01”,或者如果您打算试用该预览版 SDK,则在您的 build.gradle 文件中将 compileSdkPreview 设置为“UpsideDownCake”。
我找到了另一种方法来解决这个问题。 我们不能强制将所有项目依赖项更新为 androidx.core:core-ktx:1.9.0,因为我使用过很多使用该库旧版本的库。
降级 Gradle 版本从 7.4 到 7.3 对我有用。
我的Android Studio版本:version 15 (Dolphin), 2021.3.1 Patch 1
我的新
Android Gradle 插件版本 7.1.1 || Gradle 版本 7.3
检查你的依赖关系并确保明确指定你要使用的确切版本,我遇到了这个问题,这是一个多模块项目
改变
1.9.0
到
core-ktx:+
或更高版本的稳定版本
implementation("androidx.core:core-ktx:+")
是在模块的 androidx.core:core:
,这将使 Gradle 引入最新版本的依赖项。
这是 Gradle 会通过以下消息警告您:避免在版本号中使用+;可能导致不可预测和不可重复的构建。
找到依赖项并给它一个特定的版本而不是
build.gradle
应该可以解决这个问题。
首先,将这些依赖项添加到您的
androidx.core:core-ktx:+
(模块)文件并同步。+
我想你的问题会得到解决...从 googlePlayServicesLocationVersion =“20.0.0”降级到“19.0.0”有帮助。
项目结构 > 依赖项 > app > core-ktx+ > 请求的版本
改成“1.9.0”
申请。