Flutter The minCompileSdk 31 specified in a dependency's AAR metadata is greater than this module's compileSdkVersion android-30 - flutter

while running Flutter debug following error has arisen,
FAILURE: Build failed with an exception.
* 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-beta01.
AAR metadata file: /home/javeed/.gradle/caches/transforms-2/files-2.1/9d7505e2cdbb28aad564446b7c211aea/work-runtime-2.7.0-beta01/META-INF/com/android/build/gradle/aar-metadata.properties.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 19s
The build failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetifier to solve the incompatibility.
Building plugin device_info...
Exception: The plugin device_info could not be built due to the issue above.
Exited (sigterm)

Try adding this snippet in the app/build.gradle file above the android {...}
configurations.all {
resolutionStrategy { force 'androidx.work:work-runtime:2.6.0' }}

Search for compileSdkVersion 31 globally and replace it with compileSdkVersion 30

Change compileSdkVersion to 31 in your android/app/build.gradle. You are trying to use a library that requires the compile SDK version to be at least 31. The library seems to be work-runtime-2.7.0-beta01 so using a lower version, which does not have this requirement, can also be a solution.

Related

Build failed with an exception flutter project

i get flutter project source code from my teacher to run into my computer...
and I'm an absolute beginner...
I found errors and I don't know why cause the code is running normally on my teacher's computer
the debug console error is
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> 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.window:window-java:1.0.0-beta04.
AAR metadata file: C:\Users\manou\.gradle\caches\transforms-2\files-2.1\625039eaad011f884ddd84f857a44b7f\jetified-window-java-1.0.0-beta04\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.window:window:1.0.0-beta04.
AAR metadata file: C:\Users\manou\.gradle\caches\transforms-2\files-2.1\a78fdf90e4c1f8464b19895cfb365f3f\jetified-window-1.0.0-beta04\META-INF\com\android\build\gradle\aar-metadata.properties.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 17s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
can you please help me with that
Just go to android/app/build.gradle and change compileSdkVersion to 31

Flutter Run failed in clone project

I copy a project from a folder then I paste in another folder. And when I open it in android studio then this project not build. Showing some error.
**FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
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.
AAR metadata file: C:\Users\NTH.gradle\caches\transforms-2\files-2.1\518cb1a6f0b0a7c96a4aac4218e13c11\jetified-core-ktx-1.7.0\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.
AAR metadata file: C:\Users\NTH.gradle\caches\transforms-2\files-2.1\1978c8540575e4da29114a40e6bf1a1a\core-1.7.0\META-INF\com\android\build\gradle\aar-metadata.properties.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 17s
Exception: Gradle task assembleDebug failed with exit code 1**

i am getting Gradle task assembleDebug failed with exit code 1

Hi i am new to flutter and i tried to clone a github repo and this is the error i cant seem to solve on my own.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
One or more issues found when checking AAR metadata values:
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-29).
Dependency: androidx.window:window-java:1.0.0-beta04.
AAR metadata file: C:\Users\alpha\.gradle\caches\transforms-3\41a83d0cf61e3d2ab42ea706b65148ab\transformed\jetified-window-java-1.0.0-beta04\META-INF\com\android\build\gradle\aar-metadata.properties.
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-29).
Dependency: androidx.window:window:1.0.0-beta04.
AAR metadata file: C:\Users\alpha\.gradle\caches\transforms-3\bb9a53f8c4dc071c681fa071739dc70b\transformed\jetified-window-1.0.0-beta04\META-INF\com\android\build\gradle\aar-metadata.properties.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 1s
Exception: Gradle task assembleDebug failed with exit code 1
Open the build.gradle file on android/app folder and set the compileSdkVersion & targetSdkVersion to 31 and set the minSdkVersion to 21 so that it would be compatible to older versions of android.
Do a flutter clean just to be safe before rebuilding the app.
Another quick solution that's worth trying (doesn't work every time, but there's no harm in trying) is to run the command:
flutter clean
in the terminal and then try rerunning the project.

Error while trying to debug flutter app on physical android phone

I'm getting this error when I try to debug my flutter application on my android physical device .
This is my debug console output :
Launching lib\main.dart on SM A515F in debug mode...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> One or more issues found when checking AAR metadata values:
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-28).
Dependency: androidx.window:window-java:1.0.0-beta04.
AAR metadata file: C:\Users\Administrator\.gradle\caches\transforms-3\598e97d118bac3af7420b509a0bba7ba\transformed\jetified-window-java-1.0.0-beta04\META-INF\com\android\build\gradle\aar-metadata.properties.
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-28).
Dependency: androidx.window:window:1.0.0-beta04.
AAR metadata file: C:\Users\Administrator\.gradle\caches\transforms-3\39a13d14d6cfd824e114bd3c6574b2e2\transformed\jetified-window-1.0.0-beta04\META-INF\com\android\build\gradle\aar-metadata.properties.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 8s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
The error is on this line of the output
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-28).
minCompileSdk must be lesser than compileSdkVersion. Correct it the build.gradle file (or inside the file showed in the error if the versions are right in the build.gradle) .

Exception: Gradle task assembleDebug failed with exit code 1 flutter project

I am running one of my old flutter project in the latest version of android studios and I am facing the issue while running the project please can you help me with this.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
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.window:window-java:1.0.0-beta04.
AAR metadata file: C:\Users\disha.gradle\caches\transforms-2\files-2.1\625039eaad011f884ddd84f857a44b7f\jetified-window-java-1.0.0-beta04\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.window:window:1.0.0-beta04.
AAR metadata file: C:\Users\User_Name.gradle\caches\transforms-2\files-2.1\a78fdf90e4c1f8464b19895cfb365f3f\jetified-window-1.0.0-beta04\META-INF\c
om\android\build\gradle\aar-metadata.properties.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 8s
Running Gradle task 'assembleDebug'... 9.5s
Exception: Gradle task assembleDebug failed with exit code 1
Solution of the error
the error is kind of obvious , As the log says
"The minCompileSdk (31) is greater than this module's
compileSdkVersion (android-30)"
which means you are trying to run a project with a minimum android api version of 31 on the emulator or device with the android api version of 30 .
Solution 1 : Reduce the SDK version for the project (Which is not recommended because you have increased it for a reason )
Solution 2 : Change the emulator or the device for debug .
For more guides on android api version : check here
But you might run into more gradle failures , AS ALWAYS , hope not but if you did please make a new issue .
What you need to do is to update your build.gradle file in android/app folder.
Set the following to this values:
compileSdkVersion 31
minSdkVersion 19 or (Lower if you want to cater older versions)
targetSdkVersion 31