Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Flutter Android build: uses-sdk:minSdkVersion cannot be smaller than the version declared in a library

Erroruses-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.

  • Applies to Flutter 3.35, Android Gradle Plugin 8.x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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.xml
  2. 2Match what you see, then jump to its fix

    1. 1The 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. 2The 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. 3You cannot raise minSdk because of a product requirement.Only if you must keep a lower minSdk: tools:overrideLibraryFix

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/null

2Fix

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 run

Confirmed by developer.android.com

Did this fix it?

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.xml

2Fix

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 --debug

Confirmed by developer.android.com

Did this fix it?

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.xml

2Fix

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 --debug

Confirmed by developer.android.com

Did this fix it?

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:

Related fixes

Mobile 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 fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.