'After a Flutter upgrade, I am getting the error "Could not resolve all files for configuration ':app:debugRuntimeClasspath'"

When I upgraded Flutter from Flutter 2.10.2 to a newer version, I got this error on every Flutter project I had created. Even when I created the new Flutter project (the simple counter app) when I am going to run the app, I am getting this error.

Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not resolve io.flutter:x86_debug:1.0.0-bd539267b42051b0da3d16ffa8f48949dce8aa8f. Required by: project :app
> Could not resolve io.flutter:x86_debug:1.0.0-bd539267b42051b0da3d16ffa8f48949dce8aa8f.
> Could not parse POM https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-bd539267b42051b0da3d16ffa8f48949dce8aa8f/x86_debug-1.0.0-bd539267b42051b0da3d16ffa8f48949dce8aa8f.pom


Solution 1:[1]

Limit work-runtime to 2.6.0 for projects using compileSdkVersion 30 or older to prevent build errors.

For fixing it, there are two ways:

  1. Change your compileSdkVersion = 31 in your android/build.gradle like below

    buildscript {
        ext {
            compileSdkVersion = 31
            ...
        }
        repositories {
            ...
        }
        dependencies {
            ...
        }
    }
    
  2. And the other one is if you don't want to upgrade to SDK 31, then add the below code in file android/app/build.gradle:

    android {
         ...
         defaultConfig {
             ...
             configurations.all {
                 resolutionStrategy { force 'androidx.work:work-runtime:2.6.0' }
             }
         }
     }
    

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 Peter Mortensen