Reputation: 18117
I have created a new Flutter project, and this is how the minSdkVersion looks like in the app/build.gradle
file:
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.projectname"
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Where is the value of flutter.minSdkVersion
set?
Note that previously, that config value looked like the following:
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.projectname"
minSdkVersion 19 //*** This is the part that needs to be changed, previously was 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Also, this is the content of the android/local.properties
file:
sdk.dir=/Users/usernaem/Library/Android/sdk
flutter.sdk=/Users/username/flutter
flutter.buildMode=release
flutter.versionName=1.0.0
flutter.versionCode=1
As you can see, the value of flutter.minSdkVersion
is not set there, but the project can be compiled and built successfully.
Where are the flutter.minSdkVersion
and flutter.targetSdkVersion
variables initialized?
P.S. related issue: https://github.com/flutter/flutter/issues/95533
Upvotes: 32
Views: 8795
Reputation: 199
Go to this file in your flutter extracted folder:
flutter/packages/flutter_tools/gradle/flutter.gradle
There you can find all static variables.
repository source for the value for readers without a flutter install: https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/android/gradle_utils.dart#L42
Upvotes: 19
Reputation: 750
To complement Jay Goti
's answer. On a newer Flutter project (3.13.9), the file at flutter/packages/flutter_tools/gradle/flutter.gradle
will only have the following two lines:
def pathToThisDirectory = buildscript.sourceFile.parentFile
apply from: "$pathToThisDirectory/src/main/groovy/flutter.groovy"
So you have to refer to the mentioned file instead, at:
flutter/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy
There you'll find all the info:
...
/** Sets the compileSdkVersion used by default in Flutter app projects. */
static int compileSdkVersion = 33
/** Sets the minSdkVersion used by default in Flutter app projects. */
static int minSdkVersion = 19
/** Sets the targetSdkVersion used by default in Flutter app projects. */
static int targetSdkVersion = 33
...
Upvotes: 8
Reputation: 162
Follow the path /android/app/build.gradle
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.sample.com"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion 23
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
Upvotes: -1
Reputation: 79
Just replace flutter.minSdkVersion
with your required value such as 19
like old style
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.projectname"
minSdkVersion 19
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Upvotes: 2
Reputation: 609
Put in your android/local.propertie
file the variable:
Example:
flutter.minSdkVersion=21
And change in android/app/build.gradle
localProperties.getProperties('flutter.minSdkVersion') // flutter.minSdkVersion
Upvotes: -1