Skip to main content

Flutter Change minSdkVersion Not Present in Fix

Hello guys, We all have heard about minimum SDK versions in android for a long time. Minimum SDK versions determines the minimum app android version on which the app runs. At present time Google play store required minimum sdk version should be set at 21 which is Android version 5. If you are using minimum SDK version below then 21 then you might face problem running latest dependencies in your flutter project.

Flutter Change minSdkVersion Not Present in Fix

In flutter project by default the minSdkVersion is set to 16 which is hardcoded and found in flutter SDK package. Here below is the complete Path for hard coded minSdkVersion.

But we do not need to change the minSdkVersion in the hard coded file. We simply call it from file by creating a new variable.

Flutter Change minSdkVersion Not Present in Fix:

1.Open your flutter project's file in code editor. The file is present in Your Flutter Project -> android -> .
local properties file location in flutter project
2. Create a variable named as flutter.minSdkVersion with API level 21.
Source code of my file after adding above min sdk version.
sdk.dir=D:\\Android\\SDK Manager
3. Open build.gradle file present in Your Flutter Project -> android -> app -> build.gradle .
Build.gradle file location in flutter app
4. Find minSdkVersion and replace its value with localProperties.getProperty('flutter.minSdkVersion') .
minSdkVersion localProperties.getProperty('flutter.minSdkVersion')
Default Config code after adding above line in build.gradle file:
    defaultConfig {
        // TODO: Specify your own unique Application ID (
        applicationId "com.example.myapp"
        // You can update the following values to match your application needs.
        // For more information, see:
        // Old Line = minSdkVersion flutter.minSdkVersion
        minSdkVersion localProperties.getProperty('flutter.minSdkVersion')
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
Now you are good to go your minSdkVersion is successfully changed with new version.
5. Clean the old android Gradle by executing below command.
cd android && gradlew clean && cd ..
Screenshot after cleaning Gradle:
Clean Android Gradle using Command