Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are "flutter.targetSdkVersion", "flutter.compileSdkVersion" and "flutter.minSdkVersion" configurable?

Recently I've noted Flutter has done some changes to android\app\build.gradle, it is not using numeric values for compileSdkVersion, minSdkVersion and targetSdkVersion anymore, instead it is using flutter.compileSdkVersion, flutter.minSdkVersion and flutter.targetSdkVersion respectively.

So my question is: Where/How are those values configured? because I don't find info on Web.

like image 903
Ουιλιαμ Αρκευα Avatar asked Apr 24 '26 04:04

Ουιλιαμ Αρκευα


2 Answers

You can set these values on android/local.properties like so,

flutter.versionCode=1
flutter.versionName=1.0.0
flutter.minSdkVersion = 21
flutter.targetSdkVersion = 29
flutter.compileSdkVersion = 30
flutter.ndkVersion=21.0.6011959

Update version numbers as required.

like image 198
Alish Giri Avatar answered Apr 26 '26 18:04

Alish Giri


In a Flutter project, when you see a line like targetSdkVersion flutter.targetSdkVersion in your build.gradle file (typically located in android/app/build.gradle), it's a reference to a variable that Flutter dynamically sets to specify the Android target SDK version for your project.

To determine the value of the flutter.targetSdkVersion, you could do the following:

You can modify your Android Gradle script to include a custom task that prints out the targetSdkVersion. Here's a small snippet you can add to your android/app/build.gradle file:

task printTargetSdkVersion {
    doLast {
        println("Target SDK Version: ${android.defaultConfig.targetSdkVersion}")
    }
}

After adding this task, you can execute it by running ./gradlew printTargetSdkVersion from your Android project directory (usually your_flutter_project/android/). This command should print the targetSdkVersion to the console like this:

Task :app:printTargetSdkVersion Target SDK Version: DefaultApiVersion{mApiLevel=33, mCodename='null'}

BUILD SUCCESSFUL in 961ms

like image 38
MeLean Avatar answered Apr 26 '26 19:04

MeLean



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!