I am using Android Studio. I am aware of the existence of these questions:
- Android minSdkVersion with Flutter(v2.8.1)
- Flutter : How to change Android minSdkVersion in Flutter Project?
The commonly suggested answer involves editing the local.properties file (it's also the answer that comes up on Google searches). I do not like that answer. Here's why:
Presently, my local.properties looks something like this:
sdk.dir=/home/{my username}/Android/Sdk
flutter.sdk=/home/{my username}/snap/flutter/common/flutter
flutter.buildMode=debug
flutter.versionName=0.0.1
flutter.versionCode=1
Note that sdk.dir
and flutter.sdk
both point to somewhere on my local system. This makes it incompatible with version control (and so local.properties is in my .gitignore file). If I were to edit it and include it in version control, it would create a situation where it might work perfectly fine on this specific computer but will not work at all if I decide to work on a different computer or someone else works on the repository from their own computer. And if I were to edit it without including it in version control, then the minimum SDK is set only on this specific computer, and any other computer will not be able to use the libraries that require that minimum SDK. So I don't understand why it's the most commonly suggested answer. Does anyone know how do to it properly? Should I just hardcode the minimum SDK version in the app build.gradle, the way it was done before Flutter 2.8?
What I've chosen to do for now is edit the app's build.gradle in the following way:
// ...
defaultConfig {
applicationId "[redacted]"
minSdkVersion Math.max(flutter.minSdkVersion, 19) // <-- Changed this line
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
// ...
Is this the proper way to do it, or even an acceptable way?