Error

Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source! Launching lib\main.dart on Android SDK built for x86 in debug mode... Running Gradle task 'assembleDebug'... FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring root project 'android'. > Could not resolve all artifacts for configuration ':classpath'. > Could not resolve com.android.tools.build:gradle:7.1.2. Required by: project : > Could not resolve com.android.tools.build:gradle:7.1.2. > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/7.1.2/gradle-7.1.2.pom'. > Could not HEAD 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/7.1.2/gradle-7.1.2.pom'. > Connect to dl.google.com:443 [dl.google.com/128.242.250.155] failed: Connection timed out: connect * 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 1m 22s

Solution

1 change the path in:"C:\Users\USERNAME\StudioProjects\ProjectName\android\gradle\wrapper\gradle-wrapper.properties"

change the last line to : distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.2-all.zip

2 change the build.gradle dependencies

{ classpath 'com.android.tools.build:gradle:7.1.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" }

7.1.2 is just the sample.