[Solved] How to solve error: app:checkDebugAarMetadata
I am trying to add google_mobile_ads, version 1.0.0 by following the steps mentioned in this answer: https://stackoverflow.com/a/67883550/13240914, but when I run the app in debug mode, I get this error:
Execution failed for task ':app:checkDebugAarMetadata'. > 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.work:work-runtime:2.7.0. AAR metadata file: /Users/mydata/.gradle/caches/transforms-2/files-2.1/6ca6bfbb6ed79157a08fdd6548cc9e4d/work-runtime-2.7.0/META-INF/com/android/build/gradle/aar-metadata.properties.
Is there any way to solve this problem? and here is android/app/build.gradle https://gist.github.com/wahyu-handayani/025cbb7c538196cf91e6629ac668954f
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).
The problem is occurring because in the dependency
androidx.work:work-runtime:2.7.0 requires minimum SDK version 31 to run. There can be two solutions:
- Use an older version of this dependency, preferably, 2.6.0
- In the app\build.gradle file, change the property
compileSdkVersion 31. Make sure to download the SDK version 31 from SDK manager first!