Search code examples
androidflutterbuild.gradlestartup

Flutter startup Error: uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library


I allready tried to change the minSdkVersion from 16 to 19 and to 21 (as flutter suggest this as a fix to that problem in the terminal). I also tried to let flutter rebuild the android folder with flutter.create . and I completely reinstalled flutter. I also changed my compileSdkVersion from 32 to 31 and did the same thing with the targetSdkVersion. But the error still occures.

The full error:

Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
Running Gradle task 'assembleDebug'...
C:\Flutter\test_project\android\app\src\debug\AndroidManifest.xml Error:
    uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:cloud_firestore] C:\Flutter\test_project\build\cloud_firestore\intermediates\merged_manifest\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="io.flutter.plugins.firebase.firestore" to force usage (may lead to runtime failures)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:cloud_firestore] C:\Flutter\test_project\build\cloud_firestore\intermediates\merged_manifest\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="io.flutter.plugins.firebase.firestore" to force usage (may lead to runtime failures)

BUILD FAILED in 21s
//Flutter Fix
Exception: Gradle task assembleDebug failed with exit code 1

My android {} in build.gradle(app):

android {
    compileSdkVersion 31
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        applicationId "com.example.test_app"
        multiDexEnabled = true
        minSdkVersion 21
        targetSdkVersion 31
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}


Solution

  • Change firebase.firestore plugin minSdkVersion 16 to 19 in library will solve the error