Flutter Android build: uses-sdk:minSdkVersion cannot be smaller than the version declared in a library
uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:cloud_firestore]Short answer
The manifest merger refuses a library whose minSdk is higher than your app's. A plugin such as cloud_firestore declares a higher level, so raise minSdk in android/app/build.gradle(.kts) to at least the number in the message. Remove a stale uses-sdk element from the manifest, since the build file overrides it anyway.
Fix it fast
1Find out which cause you have
Read the numbers in the message, then see what minSdk your app sets.
grep -n "minSdk" android/app/build.gradle.kts android/app/build.gradle 2>/dev/null; grep -n "uses-sdk" android/app/src/main/AndroidManifest.xml2Match what you see, then jump to its fix
- 1
The message gives the app number first and the library number after 'declared in library'.The app's minSdk in the build file is below the plugin'sFix - 2
The manifest still has a <uses-sdk android:minSdkVersion=...> line that differs from the Gradle value.A uses-sdk element in AndroidManifest.xml hides the real valueFix - 3
You cannot raise minSdk because of a product requirement.Only if you must keep a lower minSdk: tools:overrideLibraryFix
- 1
What does the error look like?
uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:cloud_firestore]
Cause 1 of 3
The app's minSdk in the build file is below the plugin's
1Check
A library with a higher minSdk than the main manifest causes an error by default and the library cannot be imported. The build file value is the one that counts.
grep -n "minSdk" android/app/build.gradle.kts android/app/build.gradle 2>/dev/null2Fix
Set minSdk to the library's number or higher. FlutterFire's setup guide lists Android API 24 as the platform floor for recent plugins, so a modern project can use 24 or above.
// android/app/build.gradle.kts
android {
defaultConfig {
minSdk = 24
}
}3Verify
Rebuild; the merge error should disappear.
flutter clean
flutter runConfirmed by developer.android.com
Cause 2 of 3
A uses-sdk element in AndroidManifest.xml hides the real value
1Check
Values from the build file override the matching uses-sdk attribute in the manifest, so two numbers can disagree and confuse you.
grep -n "uses-sdk" android/app/src/main/AndroidManifest.xml2Fix
Delete the uses-sdk element and keep minSdk only in the build file.
<!-- remove this line from android/app/src/main/AndroidManifest.xml -->
<uses-sdk android:minSdkVersion="16" />3Verify
Check the merged manifest in Android Studio (Merged Manifest tab) and build again.
flutter build apk --debugConfirmed by developer.android.com
Cause 3 of 3
Only if you must keep a lower minSdk: tools:overrideLibrary
1Check
The manifest merger lets an app import a higher-minSdk library with tools:overrideLibrary in uses-sdk. The library then still needs the higher Android version at run time, so only use it when that code path never runs on older devices.
grep -n "overrideLibrary" android/app/src/main/AndroidManifest.xml2Fix
Add the namespace for tools and name the library's package in the uses-sdk element.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-sdk tools:overrideLibrary="com.example.library_package" />
</manifest>3Verify
Rebuild and test on the lowest device you support.
flutter build apk --debugConfirmed by developer.android.com
How do I stop it coming back?
- Read the platform requirements on the plugin's pub.dev page before adding it.
- Keep minSdk in one place, the Gradle file, and leave uses-sdk out of the manifest.
- Upgrade FlutterFire plugins together so their floors stay aligned.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
Related fixes
Mobile apps
Flutter says plugins need a higher compileSdk or a different NDK
to be compiled against a higher Android SDK version:
Flutter checks every plugin's compileSdk and NDK version before building.
3 causes, each with a fixMobile apps
Google Play says the app does not support 16 KB memory pages
check_elf_alignment.sh reports UNALIGNED for a library under lib/arm64-v8a
Google Play requires apps that target Android 15 or higher and ship native .so libraries to run on devices with 16 KB memory pages; from 1 February 2027 it will block updates that do not.
5 causes, each with a fixMobile apps
Gradle cannot find com.google.firebase:firebase-analytics-ktx
Required by: project :app
Firebase moved the Kotlin extensions into the main modules and stopped releasing the -ktx modules in July 2025.
2 causes, each with a fixMobile apps
Gradle cannot create LibraryVariantBuilderImpl in a Flutter Android build
Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl
This error appears when the Android Gradle plugin (AGP) cannot run in the Gradle or IDE you use.
3 causes, each with a fixMobile apps
Flutter release build cannot open the keystore: HmacPBESHA256 not available
Algorithm HmacPBESHA256 not available
The keystore is a PKCS12 file protected by a newer algorithm than the Java that is reading it understands.
3 causes, each with a fixMobile apps
Android install error: the package conflicts with an existing package of the same name
The package conflicts with an existing package by the same name
Android allows only one app per application ID, and an update must be signed with the same certificate as the installed version.
3 causes, each with a fix