'Execution failed for task ':app:checkDebugAarMetadata
- What went wrong: 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-rc01. AAR metadata file: C:\Users\100812.gradle\caches\transforms-2\files-2.1\8fcba37f766c3622d8dbd30df4e98577\work-runtime-2.7.0-rc01\META-INF\com\android\build\gradle\aar-metadata.properties.
Solution 1:[1]
The minCompileSdk
is 31, but the minSdkVersion
is significantly lower. Increasing the compileSdk
of your project is enough to fix the issue. There is no need for overrides or even changing the targetSdk
.
android {
compileSdk 31
...
}
compileSdkVersion
from 29 to 31
targetSdkVersion
from 29 to 31
Solution 2:[2]
you can find the compileSdkVersion under: android > app > build.gradle
android {
compileSdkVersion 31
...
}
Solution 3:[3]
Check with your configuration in android/app/src/build.gradle file with new version of flutter compileSdk and targetSdkVersion are mention as below
android {
compileSdkVersion flutter.compileSdkVersion
.....
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.app"
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Solution 4:[4]
I had faced the same issue, In case you cloned a GitHub repository and then when you run that code this is the error that comes up(as it happened with me) then Solution :
Step 1 : Create a new flutter project at your local system
Step 2 : Copy the code given in main.dart
file of stub project and paste it into main.dart
file of your local project
Step 3 : Make an 'assets' folder in your local project
Step 4 : download asset-files from GitHub and put them into your local 'assets' folder
Step 5 : in your local pubspec.yaml
file, add dependency for your 'assets' folder
Step 6 : Rename MyApp()
in widget testing file to MaterialApp()
Hit save(in files other than pubspec.yaml
), get all dependencies(in pubspec.yaml
) and you're good to go
In short : Copy the required code and the dependencies you want Then Save the changes and run
Error was there in my case mainly because the Flutter V2 has many changes and the code was outdated.
Solution 5:[5]
Go to android/app/build.gradle
Change: From: compileSdkVersion 29 To: compileSdkVersion 31
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Anmol Mishra |
Solution 2 | Manishyadav |
Solution 3 | Umesh Tikhe |
Solution 4 | user18520267 |
Solution 5 | Lance Olana |