英文:
Issues were found when checking AAR metadata: androidx.core:core:1.12.0-alpha01 and androidx.core:core-ktx:1.12.0-alpha01
问题
I am working on a project and today the build is not working anymore.
The error is the following:
> 2 issues were found when checking AAR metadata:
>
> 1. Dependency 'androidx.core:core:1.12.0-alpha01' requires libraries and applications that
> depend on it to compile against codename "UpsideDownCake" of the
> Android APIs.
>
> :app is currently compiled against android-33.
>
> Recommended action: Use a different version of dependency 'androidx.core:core:1.12.0-alpha01',
> or set compileSdkPreview to "UpsideDownCake" in your build.gradle
> file if you intend to experiment with that preview SDK.
>
> 2. Dependency 'androidx.core:core-ktx:1.12.0-alpha01' requires libraries and applications that
> depend on it to compile against codename "UpsideDownCake" of the
> Android APIs.
>
> :app is currently compiled against android-33.
>
> Recommended action: Use a different version of dependency 'androidx.core:core-ktx:1.12.0-alpha01',
> or set compileSdkPreview to "UpsideDownCake" in your build.gradle
> file if you intend to experiment with that preview SDK.
From my research, I understand that the version from the error message were released yesterday, according to the official documentation.
Below are the build.gradle scripts that the project is using.
In my build.gradle I have implementation 'androidx.core:core-ktx:1.9.0'
. I don't understand why another version is added at the build phase and also why androidx.core:core:1.12.0-alpha01
is added.
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 (app):
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.
英文:
I am working on a project and today the build is not working anymore.
The error is the following:
> 2 issues were found when checking AAR metadata:
>
> 1. Dependency 'androidx.core:core:1.12.0-alpha01' requires libraries and applications that
> depend on it to compile against codename "UpsideDownCake" of the
> Android APIs.
>
> :app is currently compiled against android-33.
>
> Recommended action: Use a different version of dependency 'androidx.core:core:1.12.0-alpha01',
> or set compileSdkPreview to "UpsideDownCake" in your build.gradle
> file if you intend to experiment with that preview SDK.
>
> 2. Dependency 'androidx.core:core-ktx:1.12.0-alpha01' requires libraries and applications that
> depend on it to compile against codename "UpsideDownCake" of the
> Android APIs.
>
> :app is currently compiled against android-33.
>
> Recommended action: Use a different version of dependency 'androidx.core:core-ktx:1.12.0-alpha01',
> or set compileSdkPreview to "UpsideDownCake" in your build.gradle
> file if you intend to experiment with that preview SDK.
From my research, I understand that the version from the error message were released yesterday, according to the official documentation.
Below are the build.gradle scripts that the project is using.
In my build.gradle I have implementation 'androidx.core:core-ktx:1.9.0'
. I don't understand why another version is added at the build phase and also why androidx.core:core:1.12.0-alpha01
is added.
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 (app):
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'
}
答案1
得分: 43
我今天也遇到了相同的错误,以下是解决方法:在build.gradle
文件中检查所有的库模块,你可以在Android Studio中使用编辑 → 查找 → 在文件中查找... 菜单选项来搜索,寻找以下导入语句:
implementation 'androidx.core:core-ktx:+'
将其替换为最新的稳定版本以避免错误:
implementation 'androidx.core:core-ktx:1.9.0'
同步你的项目,错误应该就会消失!
英文:
I had the same error today, and this is what fixed it for me: check in all your library modules for this import in the build.gradle
files (you can search in Android Studio in the Edit → Find → Find in Files... menu option):
implementation 'androidx.core:core-ktx:+'
Replace it with the latest stable version to avoid the error:
implementation 'androidx.core:core-ktx:1.9.0'
Synchronise your project and the errors should be gone!
答案2
得分: 20
我有相同的问题。添加这一行;这与Android 14的更改相关:
defaultConfig {
compileSdkPreview = "UpsideDownCake"
}
英文:
I have the same problem. Add this line; it's related to Android 14 changes:
defaultConfig {
compileSdkPreview = "UpsideDownCake"
}
答案3
得分: 14
我有同样的问题,但我的项目没有这个通用依赖:
androidx.core:core-ktx: +
但是我的一些依赖项中有它(你可以在Gradle的“依赖分析器”中看到它)。所以你需要告诉Gradle为你的依赖项强制指定一个特定的版本:
configurations.all {
resolutionStrategy {
force("androidx.core:core-ktx:1.9.0")
}
}
英文:
I had the same problem, but my project didn't have this generic dependency:
androidx.core:core-ktx:+
But some of my dependencies had it (you can see it with the Gradle "Dependency analyser"). So you need to tell Gradle to force a specific dependency version for your dependencies:
configurations.all {
resolutionStrategy {
force("androidx.core:core-ktx:1.9.0")
}
}
答案4
得分: 13
仔细检查您的依赖项,并确保明确指定您将使用的确切版本,我曾遇到过这个问题,因为我在某些模块中使用了 1.9.0
,而在某些模块中使用了 core-ktx:+
。
只需将
implementation("androidx.core:core-ktx:+")
更改为
implementation("androidx.core:core-ktx:1.9.0")
或者更晚的稳定版本。
英文:
Go through your dependencies and make sure to specify explicitly the exact version you'd be using, I had this issue and it is a multi-module project I used 1.9.0
in some modules and in some modules I used core-ktx:+
.
just change
implementation("androidx.core:core-ktx:+")
to
implementation("androidx.core:core-ktx:1.9.0")
or a later stable version
答案5
得分: 4
我遇到了同样的问题。
这有帮助:
defaultConfig {
compileSdkPreview = "UpsideDownCake"
}
但在创建APK文件/捆绑包时出现了问题,所以对我来说最好的解决方案是降级Gradle。
Android Gradle插件版本7.1.1 || Gradle版本7.3
英文:
I had the same problem.
This helped:
defaultConfig {
compileSdkPreview = "UpsideDownCake"
}
But it created a problem at the moment of creating the APK file/bundle, so the best solution for me was to downgrade Gradle.
Android Gradle Plugin Version 7.1.1 || Gradle Version 7.3
答案6
得分: 3
这是对我有效的部分:
项目结构 > 依赖项 > 应用程序 > core-ktx+ > 请求的版本
将其更改为 "1.9.0"
应用。
英文:
Here's what worked for me :
Project Structure > Dependencies > app > core-ktx+ > Requested Version
Change it to "1.9.0"
Apply.
答案7
得分: 2
androidx.core:core:
是您模块的build.gradle
中声明的依赖项,或作为项目的传递性依赖项引入的。很有可能它被声明为androidx.core:core-ktx:+
,这将使Gradle引入依赖项的最新版本。
这是Gradle会通过以下消息警告您的一种情况:
避免在版本号中使用 +,可能会导致构建不可预测和不可重复。
找到该依赖项并为其指定一个特定的版本而不是+
应该解决这个问题。
英文:
androidx.core:core:
is either a dependency declared in your module's build.gradle
or pulled in as a transitive dependency into your project. There's a good chance that it is declared as androidx.core:core-ktx:+
which will make Gradle pull in the latest version of your dependency.
This is something Gradle will warn you against with the message:
> Avoid using + in version numbers; can lead to unpredictable and unrepeatable builds'.
Finding the dependency and giving it a specific version instead of +
should fix the issue.
答案8
得分: 1
就像Aleksandr Zurnachyan所说的。
我面临着同样的问题。
建议操作:如果您打算尝试使用该预览SDK,请使用不同版本的依赖项'androidx.core:core:1.12.0-alpha01',或在您的build.gradle文件中将compileSdkPreview设置为"UpsideDownCake"。
英文:
Like Aleksandr Zurnachyan said.
I face the same problem.
Recommended action: Use a different version of dependency 'androidx.core:core:1.12.0-alpha01', or set compileSdkPreview to "UpsideDownCake" in your build.gradle file if you intend to experiment with that preview SDK.
答案9
得分: 1
我找到了另一种解决这个问题的方法。
我们不能强制更新所有项目依赖项到androidx.core:core-ktx:1.9.0,因为我使用了许多使用较旧版本的此库的库。
对我有效的解决方案
将Gradle版本从7.4降级到7.3对我有效。
我的Android Studio版本:版本 15(Dolphin),2021.3.1 Patch 1
我的新的
Android Gradle 插件版本 7.1.1
|| Gradle 版本 7.3
英文:
I have found another way to fix this issue.
We can't force update all project dependencies to androidx.core:core-ktx:1.9.0, because I have used many libraries which uses older version of this library.
A solution that worked for me
Downgrading Gradle version from 7.4 to 7.3 worked for me.
My Android Studio version: version 15 (Dolphin), 2021.3.1 Patch 1
My New
Android Gradle Plugin Version 7.1.1
|| Gradle Version 7.3
答案10
得分: 0
首先,将这些依赖项添加到您的build.gradle
(模块)文件中并进行同步。
implementation("androidx.core:core-ktx:$core_version")
implementation("androidx.core:core-role:1.0.0")
我认为您的问题将会得到解决。
英文:
First, add these dependencies to your build.gradle
(Module) file and sync.
implementation("androidx.core:core-ktx:$core_version")
implementation("androidx.core:core-role:1.0.0")
I think your problem will be solved...
答案11
得分: 0
降级从 googlePlayServicesLocationVersion = "20.0.0" 到 "19.0.0" 有所帮助。
英文:
Downgrading from googlePlayServicesLocationVersion = "20.0.0" to "19.0.0" helped.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论