添加 cloud_firebase 包后我的 Flutter 应用程序未运行

eng*_*gPS 8 android gradle firebase flutter

最近我在我的 flutter 项目中添加了 firebase。为了使用 firebase 数据库服务,我添加了 cloud_firebase 包。但添加此包后,我的应用程序未运行并给了我一个例外:

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
Run Code Online (Sandbox Code Playgroud)

异常消息还提出以下建议

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)
Run Code Online (Sandbox Code Playgroud)

我已经尝试了前两个建议,但该应用程序仍然无法运行。

eng*_*gPS 18

在project_folder/android/app/build.gradle 中将 minSdkVersion 更改为 21 后它将起作用。

defaultConfig {
        minSdkVersion 21
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }
Run Code Online (Sandbox Code Playgroud)


trm*_*trm 5

对于Flutter 2.8更新后创建的项目

\n
    \n
  1. 将其添加到project_folder/android/local.properties

    \n

    flutter.minSdkVersion=21

    \n
  2. \n
  3. 现在更新您的project_folder/android/app/build.gradle

    \n

    defaultConfig { minSdkVersion localProperties.getProperty(\'flutter.minSdkVersion\').toInteger() }

    \n
  4. \n
  5. 跑步flutter clean && flutter pub get

    \n
  6. \n
  7. 重新运行应用程序

    \n
  8. \n
\n

参考:更改 Flutter\xe2\x80\x8a \xe2\x80\x93 \xe2\x80\x8a2 中的 Android Minsdkversion Easy Ways [2022]

\n