How can I resolve the error The minCompileSdk (31) specified in a dependency's AAR metadata in native Java or Kotlin?
I have found the solution. Enter this line of code above package in the app Gradle file.
For Kotlin developers:
configurations.all {
resolutionStrategy { force 'androidx.core:core-ktx:1.6.0' }
}
For Java developers
configurations.all {
resolutionStrategy { force 'androidx.core:core:1.6.0' }
}
How can I resolve the error The minCompileSdk (31) specified in a dependency's AAR metadata in native Java?
The error message hints at how to resolve the issue. The minCompileSdk can never be higher than your compileSdkVersion which is also hinted in the name of the parameters, as the minCompileSdk is the minimum SDK you want to support, so setting it to a higher value than the compileSdkVersion should intuitively mean that it won't be the minimum sdk version needed.
Either downgrade your minCompileSdk to 30 og upgrade your compileSdkVersion to 31, to fix this issue. You can read more about these parameters in this thread: What is the difference between compileSdkVersion and targetSdkVersion?
minCompileSDK specified in dependency AAR metadata (androidx.window:window:1.0.0-beta04)
replace this code:
android {
compileSdkVersion 30
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
applicationId "com.example.r_app"
minSdkVersion 21
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
...........
dependencies {
implementation platform('com.google.firebase:firebase-bom:28.0.1')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
by the following
android {
compileSdkVersion 31
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
applicationId "com.example.r_app"
minSdkVersion 21
targetSdkVersion 31
multiDexEnabled true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
.......and.......
dependencies {
implementation platform('com.google.firebase:firebase-bom:28.0.1')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.guava:guava:27.0.1-android'
}
and add the line classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
in project_file -> android -> build.gradle :
dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
......
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
After that open for editing in Android Studio
on the top right.. Allow it to build. then Run. If required - flutter clean - pub_get in pubspec.yaml. I think this should work.. Because I am not sure what other requirements or errors you are getting.
Android app won't build -- The minCompileSdk (31) specified in a dependency's androidx.work:work-runtime:2.7.0-beta01
The error is being caused because one of your dependencies is internally using WorkManager 2.7.0-beta01 that was released today (which needs API 31). In my case it was CheckAarMetadata.kt
.
You can fix it by forcing Gradle to use an older version of Work Manager for the transitive dependency that works with API 30. In your build.gradle
file add:
dependencies {
def work_version = "2.6.0"
// Force WorkManager 2.6.0 for transitive dependency
implementation("androidx.work:work-runtime-ktx:$work_version") {
force = true
}
}
This should fix it.
The minCompileSdk (31) specified
Add this line of code in-app `build.gradle file.
configurations.all {
resolutionStrategy { force 'androidx.core:core-ktx:1.6.0' }
}
One or more issues found when checking AAR metadata values:
Change your compileSdk 30
to 31.
It worked for me!
compileSdk 31
defaultConfig {
applicationId "com.example.lifecycle"
minSdk 21
targetSdk 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Related Topics
What Is the Basic Purpose of @Serializedname Annotation in Android Using Gson
How to Get String Array from Arrays.Xml File
How to Change Color of Hamburger Icon in Material Design Navigation Drawer
Which Android Data Storage Technique to Use
How to Change Text of a Textview in Navigation Drawer Header
How to Convert Firebase Data to Java Object...
How to Disable Sslv3 in Android for Httpsurlconnection
What Is Fatal Signal 6 in Android Logcat
What Is Difference Between @+Id/Android:List and @+Id/List
Send Sms Until It Is Successful
Change Listview Background - Strange Behaviour
How to Allow Users to Check for the Latest App Version from Inside the App
How to Get Difference Between Two Dates in Android, Tried Every Thing and Post
Android.App.Application Cannot Be Cast to Android.App.Activity