10

On file build.gradle I found code like this

minSdkVersion flutter.minSdkVersion

targetSdkVersion flutter.targetSdkVersion

How can I change the values from where they are initialized ? 1

rachidev
  • 101
  • 1
  • 1
  • 3
  • I open android Studio File -> Project Structure -> Modules -> Default Config and select Target SDK Version And Min SDK Version – mario francois Dec 13 '21 at 22:16
  • Check out my answer https://stackoverflow.com/questions/52060516/how-to-change-android-minsdkversion-in-flutter-project/70452027#70452027 – Mr Random Dec 22 '21 at 16:20

3 Answers3

10

You can simply change these in android/local.properties file.

define or change them inside android/local.properties:

org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true

// add these lines
flutter.minSdkVersion=21
flutter.targetSdkVersion=29
Sajad Abdollahi
  • 1,593
  • 1
  • 7
  • 19
  • 5
    Thank you so much but if you don't mind can you check this file: C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle inside file flutter.gradle there's : Class FlutterExtension { static int compileSdkVersion = 31 /** Sets the minSdkVersion used by default in Flutter app projects. */ static int minSdkVersion = 16 /** Sets the targetSdkVersion used by default in Flutter app projects. */ static int targetSdkVersion = 31 } – rachidev Dec 18 '21 at 01:23
  • @rachidev So what is wrong with this file? – Sajad Abdollahi Dec 18 '21 at 20:23
  • 2
    Nothing wrong, but I guess this is the source where flutter get the values of flutter.minSdkVersion and flutter.targetSdkVersion – rachidev Dec 19 '21 at 01:07
8

flutter 2.9.2 in [prj]/android/app/src/build.gradle change :

minSdkVersion flutter.minSdkVersion

to (for example) :

minSdkVersion localProperties.getProperty('flutter.minSdkVersion')

and in [prj]/android/local.properties add/change:

flutter.minSdkVersion=XX
kaa
  • 91
  • 2
  • 3
0

Replace

minSdkVersion flutter.minSdkVersion

targetSdkVersion flutter.targetSdkVersion

With this

minSdkVersion 21

targetSdkVersion 31

versionCode flutterVersionCode.toInteger()

versionName flutterVersionName