Adjusting MinSdkVersion in Flutter for Android: 2 Simple Approaches [2023]

3 min read

Integrating external packages into your app can significantly streamline development, allowing you to focus on your app’s core functionality. However, sometimes this process triggers a requirement to increase the Android minSdkVersion due to the plugin’s demands. This scenario applies to projects created both before and after the Flutter 2.8 update. In this comprehensive tutorial, we’ll delve into how to modify the Android 'minSdkVersion' '(flutter.minsdkversion)' in Flutter, covering two distinct approaches for different project timelines.

Ways to Change Android MinSdkVersion in Flutter

Let’s explore the two methods to modify the Android minSdkVersion. The first method applies to projects initiated prior to the Flutter 2.8 update, while the second is tailored for projects commenced after the update.

For Projects Created Before Flutter 2.8 Update

For projects established prior to the 2.8 update, follow these steps to adjust the 'minSdkVersion' in your Flutter app:

  1. Locate the 'build.gradle' File: Navigate to the 'android/app directory' within your Flutter project. Inside this directory, locate and open the 'build.gradle' file using a text editor.

  2. Update the minSdkVersion: Inside the 'build.gradle' file, locate the 'defaultConfig' section. Modify the 'minSdkVersion' field to match your desired Android API level. For instance, to set the minimum API level to 21 (Android 5.0 - Lollipop), make the adjustment as follows:

Copy
defaultConfig {
    applicationId "com.example.common_project"
    minSdkVersion 21 // Update this line
    targetSdkVersion 30
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    // ... other configurations ...
}

Screenshot: Adjusting MinSdkVersion in Flutter for Android: 2 Simple Approaches [2023] - Mihir Pipermitwala

  1. Clean and Re-run: Save the 'build.gradle' file and execute the 'flutter clean' command in your terminal. Afterward, re-run your Flutter app.

For Projects Created After Flutter 2.8 Update

For projects initiated after the Flutter 2.8 update, altering the Android 'minSdkVersion' involves modifying the 'local.properties' file and referencing the new variable in the 'build.gradle' file. Here’s how:

  1. Locate the 'local.properties' File: Within your Flutter project, find and open the 'local.properties' file situated in the android directory.

  2. Add the 'flutter.minSdkVersion' Line: Inside the 'local.properties' file, add the following line to set the 'flutter.minSdkVersion' variable:

Copy
flutter.minSdkVersion=21
  1. Update the 'build.gradle' File: Open the 'build.gradle' file located in the 'android/app' directory. Within the 'defaultConfig' section, update the 'minSdkVersion' using the value from 'localProperties.getProperty('flutter.minSdkVersion').toInteger()'
Copy
defaultConfig {
    applicationId "com.example.sample_project"
    minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
    targetSdkVersion flutter.targetSdkVersion
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    // ... other configurations ...
}

Screenshot: Adjusting MinSdkVersion in Flutter for Android: 2 Simple Approaches [2023] - Mihir Pipermitwala

  1. Clean and Re-run: As before, save the 'build.gradle' file and execute the 'flutter clean' command in your terminal. Then, re-run your Flutter app.

Conclusion

This tutorial provided an in-depth exploration of adjusting the Android minSdkVersion (flutter.minsdkversion) in Flutter. By following the detailed steps and practical examples, you can seamlessly tailor the minimum Android API level to meet the requirements of your project. Whether you’re dealing with projects predating the Flutter 2.8 update or ones initiated thereafter, you now possess the knowledge to navigate this crucial aspect of app development.

Curious about other insightful Flutter tutorials? Explore our collection to further enhance your Flutter development expertise.

Related Blogs
Adjusting MinSdkVersion in Flutter for Android: 2 Simple Approaches [2023]

Adjusting MinSdkVersion in Flutter for Android: 2 Simple Approaches [2023]

Enhance your Flutter app's compatibility by tweaking the Android minSdkVersion. This comprehensive guide covers easy techniques for projects pre and post Flutter 2.8, guaranteeing optimal functionality.

ANDROIDFLUTTERFLUTTER DEVELOPMENTMIN SDK VERSION

July 20, 2023

Unlocking Flutter's Potential: Best Practices for Writing Clean Code

Unlocking Flutter's Potential: Best Practices for Writing Clean Code

Unlock Flutter's potential with clean code! Learn best practices for writing maintainable Dart code in Flutter. Explore examples and essential principles for code quality.

CLEAN CODECODE BEST PRACTICESCODE MAINTAINABILITYCODE ORGANIZATIONCODE READABILITY

June 02, 2023

All about SOLID Principles in Flutter: Examples and Tips

All about SOLID Principles in Flutter: Examples and Tips

Check out this guide on SOLID principles in Flutter by Mihir Pipermitwala, a software engineer from Surat. Learn with real-world examples!

DARTFLUTTERSOLID PRINCIPLES

April 11, 2023

Top 9 Local Databases for Flutter in 2023: A Comprehensive Comparison

Top 9 Local Databases for Flutter in 2023: A Comprehensive Comparison

Looking for the best local database for your Flutter app? Check out our comprehensive comparison of the top 9 local databases for Flutter in 2023.

CODINGFLUTTERFLUTTER LOCAL DATABASESLEARN TO CODENOSQL

April 06, 2023

Related Tutorials
A Comprehensive Guide to Flutter Buttons: Choosing the Right One for Your App

A Comprehensive Guide to Flutter Buttons: Choosing the Right One for Your App

A quick guide for you to understand and choose which Button widget suits your needs

FLUTTERFLUTTER BUTTONFLUTTER DEVELOPMENTTEXT BUTTON

April 17, 2024

How to Show Automatic Internet Connection Offline Message in Flutter

How to Show Automatic Internet Connection Offline Message in Flutter

You have to use the 'Connectivity Flutter Package' to achieve this feature on your App. This package helps to know whether your device is online or offline.

CONNECTIVITY PLUSDEPENDENCIESFLUTTERFLUTTER DEVELOPMENTFLUTTER PACKAGES

April 09, 2024

Mastering TabBar and TabBarView Implementation in Flutter: A Comprehensive Guide for 2023

Mastering TabBar and TabBarView Implementation in Flutter: A Comprehensive Guide for 2023

Discover the art of implementing TabBar and TabBarView widgets in Flutter with our comprehensive guide for 2023. Learn step by step how to create captivating user interfaces, customize tab indicators, enable scrollable tabs, change tabs programmatically, and more. Elevate your Flutter app's navigation and user experience with expert insights and practical examples.

CODINGDEFAULT TAB CONTROLLERFLUTTERLEARN TO CODETAB CONTROLLER

July 26, 2023

Enhancing File Manipulation in Flutter: Best Practices and Examples

Enhancing File Manipulation in Flutter: Best Practices and Examples

Master Flutter file manipulation like a pro. Our comprehensive blog provides insights on permission management, directory handling, and practical read-write scenarios. Elevate your app's file management.

CODINGFLUTTERFLUTTER DEVELOPMENTFLUTTER FILE OPERATIONFLUTTER PATH PROVIDER

June 30, 2023

Related Recommended Services
Visual Studio Code for the Web

Visual Studio Code for the Web

Build with Visual Studio Code, anywhere, anytime, in your browser.

IDEVISUAL STUDIOVISUAL STUDIO CODEWEB
Renovate | Automated Dependency Updates

Renovate | Automated Dependency Updates

Renovate Bot keeps source code dependencies up-to-date using automated Pull Requests.

AUTOMATED DEPENDENCY UPDATESBUNDLERCOMPOSERGITHUBGO MODULES
Best XML Formatter and XML Beautifier

Best XML Formatter and XML Beautifier

Online XML Formatter will format xml data, helps to validate, and works as XML Converter. Save and Share XML.

XMLXML BEAUTIFIERXML CONVERTERXML FORMATXML FORMATTER
Kubecost | Kubernetes cost monitoring and management

Kubecost | Kubernetes cost monitoring and management

Kubecost started in early 2019 as an open-source tool to give developers visibility into Kubernetes spend. We maintain a deep commitment to building and supporting dedicated solutions for the open source community.

CLOUDKUBECOSTKUBERNETESOPEN SOURCESELF HOSTED
Related Recommended Stories
Awesome Python

Awesome Python

An opinionated list of awesome Python frameworks, libraries, software and resources

AWESOMECOLLECTIONSGITHUBPYTHONPYTHON FRAMEWORK
Found means fixed - Introducing code scanning autofix, powered by GitHub Copilot and CodeQL

Found means fixed - Introducing code scanning autofix, powered by GitHub Copilot and CodeQL

Now in public beta for GitHub Advanced Security customers, code scanning autofix helps developers remediate more than two-thirds of supported alerts with little or no editing.

CODE SCANNINGCODEQLCODINGGITHUBGITHUB ADVANCED SECURITY
Awesome Java

Awesome Java

A curated list of awesome frameworks, libraries and software for the Java programming language

AWESOMEBUILDCACHINGCLICODE ANALYSIS
Awesome iOS

Awesome iOS

A curated list of awesome iOS ecosystem, including Objective-C and Swift Projects

ANALYTICSAPP ROUTINGAPP STOREAPPLE SWIFTAPPLE TV
Related Recommended Tools
Find out what websites are built with - Wappalyzer

Find out what websites are built with - Wappalyzer

Find out the technology stack of any website. Create lists of websites and contacts by the technologies they use.

ADD ONSANALYTICSAPP STOREAPPLEBOOKING
Sourcetree | Free Git GUI for Mac and Windows

Sourcetree | Free Git GUI for Mac and Windows

A Git GUI that offers a visual representation of your repositories. Sourcetree is a free Git client for Windows and Mac.

GITGITHUBGITLABATLASSIANBITBUCKET
Related Recommended Videos