The Gradle error looks like this:
uses-sdk:minSdkVersion 21 cannot be smaller than version 23 declared in library [:some_plugin]
Flutter recognises it and prints its own fix, from the Flutter tool source:
The plugin some_plugin requires a higher Android SDK version.
Fix this issue by adding the following to the file .../android/app/build.gradle:
android {
defaultConfig {
minSdkVersion 23
}
}
Following this change, your app will not be available to users running Android SDKs below 23.
Consider searching for a version of this plugin that supports these lower versions of the Android SDK instead.
The first number (21) is your app’s minimum Android API level. The second (23) is what the plugin needs. Your app can’t support older phones than its plugins do.
Fix: raise minSdk to the plugin’s number
Open android/app/build.gradle.kts (or build.gradle in older projects) and find defaultConfig:
android {
defaultConfig {
applicationId = "com.example.app"
minSdk = 23 // was 21, or flutter.minSdkVersion on an old Flutter
targetSdk = flutter.targetSdkVersion
// ...
}
}
In Groovy (build.gradle), the line is minSdkVersion 23 or minSdk 23. Then:
flutter clean
flutter run
If the error comes back with a higher number, a second plugin needs even more. Use the highest number any plugin asks for.
What Flutter itself expects
- Flutter 3.35 and 3.50 set
flutter.minSdkVersionto 24 (Android 7.0). Projects that useminSdk = flutter.minSdkVersionget 24 automatically and rarely see this error unless a plugin needs 26 or more. - Flutter 3.50 stops the build if minSdk is below 23 and warns below 24. So if you’re upgrading an old project that still says 21, you need to raise it anyway.
Should you raise it?
Usually yes. Very few active users run Android versions below 7.0, and Google Play’s own target API rules keep pushing apps forward. Check Play Console under Statistics or Android vitals, filtered by Android version, to see how many of your users are on old versions before you decide.
If you really must keep a lower minSdk, there are two options:
- Use an older version of the plugin, or a different plugin, that supports your minimum. The Flutter package checker shows which versions are current.
- Don’t force it with
tools:overrideLibraryin the manifest. It makes the build pass, but the plugin can crash on phones below its real minimum.
Frequently asked questions
What does "minSdkVersion cannot be smaller than version declared in library" mean?
A plugin in your app needs a newer minimum Android version than your app declares. The first number is your app’s minSdk, the second is the plugin’s. Raise your app’s minSdk to at least the second number.
Where do I change minSdkVersion in Flutter?
In android/app/build.gradle.kts (or build.gradle), inside android, defaultConfig: minSdk = 23 in Kotlin DSL, or minSdkVersion 23 in Groovy. New projects use flutter.minSdkVersion there, which is 24 on Flutter 3.35 and 3.50.
Will raising minSdk remove my app for existing users?
Users on Android versions below the new minimum can no longer install or update the app, but the version they already have keeps working. Check your Android version statistics in Play Console first.
Stuck on a build or a store release? I fix and maintain Flutter apps, or tell me about your project. More fixes: all Flutter answers.