7

I'm trying to add the firebase into my flutter project . I'm getting this error :

uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [com.google.firebase:firebase-analytics-ktx:20.0.1] /home/sonu/.gradle/caches/transforms-2/files-2.1/798243125f1f7594aa48e9bc333d339c/jetified-firebase-analytics-ktx-20.0.1/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="com.google.firebase.analytics.ktx" to force usage (may lead to runtime failures)

I recently updated my flutter to verison 2.8.1, I tried to change my minSdk but didn't worked.

This is the full logs:

[enter image description here][1]

Please someone help me to solve this issue.

Sonu Hansda
  • 109
  • 1
  • 2
  • 6
  • 2
    Your question has answer here https://stackoverflow.com/questions/52060516/how-to-change-android-minsdkversion-in-flutter-project – Wilfred Almeida Jan 13 '22 at 09:48
  • 1
    Go to android->app->build.gradle. In `defaultConfig{}` change minSdkVersion to 19 from 16. – Pranav Jan 13 '22 at 09:50

2 Answers2

8

android->app->build.gradle file

defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.flutter_calismalari"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

make the minSdkVersion from 16 to 21

Yunus Kocatas
  • 286
  • 2
  • 9
2

You need to update your minimum SDK in ./android/app/build.gradle Example:

defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.example.projectname"
    minSdkVersion 19 //*** This is the part that needs to be changed, previously was 16
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}