'How to change default gradle version for flutter projects

This is my build.gradle file:

buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "org.jetbrains.kotlinkotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

I know that I can change the gradle:4.1.0 to the required gradle version and then change the distributionUrl present in the gradle-wrapper.properties. But every time I create a new project I get the the same old version 4.1.0 and then I have to manually change it again. How can I set a default version for it?



Solution 1:[1]

Go to app/build.gradel add this

android {
    compileSdkVersion 31 // <-- This
    defaultConfig {
        applicationId "com.example.app"
        targetSdkVersion 31 // <-- and this too
        // ...
    }
}

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 Manishyadav