I had this issue on a react-native project that was working a few days ago, suddenly I get this error:
* What went wrong:
Execution failed for task ':app:checkDevDebugAarMetadata'.
> Multiple task action failures occurred:
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.core:core-ktx:1.7.0-alpha02.
AAR metadata file: /Users/me/.gradle/caches/transforms-2/files-2.1/ed22ee8b86d25659bbef1e9ee203b75c/jetified-core-ktx-1.7.0-alpha02/META-INF/com/android/build/gradle/aar-metadata.properties.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.core:core:1.7.0-alpha02.
AAR metadata file: /Users/me/.gradle/caches/transforms-2/files-2.1/23234efc7e9de9bfe6a3fea85a6072ef/core-1.7.0-alpha02/META-INF/com/android/build/gradle/aar-metadata.properties.
After reading the error message I understood that the problem was androidx.core:core-ktx
so I searched more about it and found that a new version has just been released last September 01 https://androidx.tech/artifacts/core/core-ktx/ which was https://androidx.tech/artifacts/core/core-ktx/1.7.0-alpha02 which has targetSdkVersion = 31
I ran grep -r "androidx.core:core-ktx" node_modules
and found that I have one dependency that has implementation "androidx.core:core-ktx:+"
which will install the latest version when I install the app. I can't just update to 31 because it seems to break the codes of some of my dependencies, I will get:
unrecognized Attribute name MODULE (class com.sun.tools.javac.util.SharedNameTable$NameImpl)
Which I don't really know how to fix and can't find any lead, it's most probably because it's new.
As a workaround, on file android/app/build.gradle
Add the following block on before android {}
block.
configurations.all {
resolutionStrategy { force 'androidx.core:core-ktx:1.7.0-alpha01' }
}
After doing this, it worked for me. It will force all androidx.core:core-ktx
to be 1.7.0-alpha01