androidfirebasefluttergradle

My Flutter App is not running after adding cloud_firebase package


Recently I have added firebase to my flutter project. To use firebase database services I have added cloud_firebase package. But after adding this package my app is not running and giving me an exception:

BUILD FAILED in 31s
The plugin cloud_firestore requires a higher Android SDK version.
Fix this issue by adding the following to the file C:\Users\Jaguar\Desktop\AppDevelopment\acadmt\android\app\build.gradle:
android {
  defaultConfig {
    minSdkVersion 19
  }
}
Note that your app won't be available to users running Android SDKs below 19.
Alternatively, try to find a version of this plugin that supports these lower versions of the Android SDK.
Exception: Gradle task assembleDebug failed with exit code 1

The exception message is also suggesting following suggestions:

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)

I have tried the first two suggestions but still, the app is not working.


Solution

  • It will work after changing the minSdkVersion to 21 at project_folder/android/app/build.gradle.

    defaultConfig {
            minSdkVersion 21
            targetSdkVersion 30
            versionCode flutterVersionCode.toInteger()
            versionName flutterVersionName
        }