With the recent 2.8 release how and where the minSdkVersion is specified has changed. It took a while to figure out, so I thought I would share this recent tip.
- January 1, 2023
When creating a flutter app the content of android\app\build.gradle is the following.
Where do these values come from?
flutter.minSdkVersion value is coming from your installed flutter SDK's flutter.gradle file which is located inside your_flutter_sdk/packages/flutter_tools/gradle/flutter.gradle
Right now Jan 2023 it looks like...
Moving forward, how do we change these defaults?
With the 2.8 release where the minimum and target SDK versions is set/established has changed within the Flutter project.
How to change Android minSdkVersion in flutter project? There are a couple approaches provided below.
Approach 1. You can change the minSdkVersion directly in the file Project_Name/android/app/build.gradle , defaultconfig
Approach 2. The more appropriate way and maintainable approach is a little more involved however I would recommend.
So here are the changes so that you can maintain the version(s) within your project.
Update the android -> local.properties adding the following 3 lines. This will be where you set the min and target versions going forward.
Add/modify to the android/src/build.gradle file
Keep in mind with this approach going forward you will maintain minimum and target SDK versions within the local.properties file.