'why i am not able to run my flutter project in android constantly getting gradle error?

image to provide more information about my problem [![* What went wrong: Could not determine the dependencies of task ':app:mergeDebugAssets'. > Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'. > Could not create task ':app:minifyReleaseWithR8'. > Failed to find Platform SDK with path: platforms;android-31

* 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 14s
Exception: Gradle task assembleDebug failed with exit code 1][1]][1]

i'm getting error constantly regarding gradle task have wasted 3 days by searching for it but didn't got any solution yet information might be needed

android/build.gradle

dependencies {
        classpath 'com.android.tools.build:gradle:7.0.2'//by default it was 4.1.2 but was getting error Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01 so I changed to 7.0.2 considering someone's suggestion
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }

gradle-wraper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip //before it was gradle-6.7


Solution 1:[1]

Failed to find Platform SDK with path: platforms;android-31 that means there is no android SDK folder

  1. to get the latest Android API on you computer, run android list target, if you don't find Android API 31 in the list, you might install it through Android studio

$ android list target

enter image description here

  1. after installing Android API 31,
  • find Android SDK Location in the project preferences
  • check whether sdk.dir is correct in "local.properties" file in android folder

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 I___