How to Change Android minSdkVersion in Flutter?
Last Updated :
08 Apr, 2023
If you are a Flutter developer, then you very well know about the minSdkVersion in Flutter. But the problem is that sometimes we need to change its value to a higher value because some package of flutter won’t work on the default minSdkVersion value 16. If you didn’t know, Google Plays tore only allows minSdkVersion to be 20 or above. But flutter has still set the default minSdkVersion to 16.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:flutter_blue] /home/maldus/Projects/flutter/polmac/build/flutter_blue/intermediates/manifests/full/debug/AndroidManifest.xml as the library might be using APIs not available in 16
Suggestion: use a compatible library with a minSdk of at most 16,
or increase this project's minSdk version to at least 19,
or use tools:overrideLibrary="com.pauldemarco.flutterblue" to force usage (may lead to runtime failures)
Flutter 2.8 or Later
build.gradle update
Before Updating to Flutter 2.8
Dart
vandroid {
compileSdkVersion 30
defaultConfig {
applicationId "com.example.app"
minSdkVersion 21
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
|
After updating to Flutter 2.8:
Dart
android {
compileSdkVersion flutter.compileSdkVersion
defaultConfig {
applicationId "com.example.app"
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
|
You should change from local.properties by the following instructions:
- First, go to the android > local.properties.
- and add the following line
flutter.minSdkVersion=23 //added line
Dart
sdk.dir=C:\\Users\\ms471\\AppData\\Local\\Android\\sdk
flutter.sdk=C:\\src\\flutter
flutter.buildMode=debug
flutter.versionName=1.0.0
flutter.versionCode=1
flutter.minSdkVersion=23
|
- And now go to the build.gradle in the app level.
- Change like this from build.gradle.
Dart
defaultConfig {
minSdkVersion localProperties.getProperty( 'flutter.minSdkVersion' ).toInteger()
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
|
Now re-restart your flutter application, You will see its work!!.
Share your thoughts in the comments
Please Login to comment...