I added a plugin and the Android build now stops with:
Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared in library [:some_plugin]
Where do I set minSdk in a recent Flutter project?
DEV3 Developer Forum
Every post is reviewed first. Usually reviewed within 24 hours.
I added a plugin and the Android build now stops with:
Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared in library [:some_plugin]
Where do I set minSdk in a recent Flutter project?
Meaning
Your app declares a lower minimum Android version than the plugin supports. Raise the app's minSdk to at least what the plugin needs (the number in the message).
Where to set it
Open android/app/build.gradle (Groovy) or android/app/build.gradle.kts (Kotlin DSL, default in newer templates).
Groovy:
android {
defaultConfig {
minSdkVersion 21 // or: minSdk = 21
targetSdkVersion flutter.targetSdkVersion
}
}
Kotlin DSL:
android {
defaultConfig {
minSdk = 23
}
}
Recent Flutter templates default to flutter.minSdkVersion, whose value rises over time (it is 24 in current stable releases, older ones used 21). Replace it with a literal number only when a plugin needs more than the default; check the plugin README for its requirement.
After changing
flutter clean
flutter pub get
flutter run
Other build-config errors people hit at the same time
flutter doctor -v and set flutter config --jdk-dir <path> if needed.settings.gradle has google() and mavenCentral().minSdk 21 or higher multidex is built in, which is another reason to raise it.Pitfall
Raising minSdk drops older devices. Check the Play Console device stats for your audience before raising it further.