我正在开发一个专门针对Android版本的flutter应用程序项目,但是在启动应用程序时,突然遇到了这个错误。我尝试了推荐解决方案中所写的内容,但它不起作用。
由于 minSdk 版本较低,构建往往会失败。
我最近添加了 Firebase cli 和 Firebase 配置等以将后端添加到我的应用程序中,在完成所有操作后它给出了此错误,但它也发生在我以前的项目中,也没有使用 firebase。
当我将 minsdk 文本粘贴到 build.grade 文件中时,它显示错误并且没有任何反应。
抱歉,如果我没有提供完整的信息,因为这是我第一次写关于SO的问题。
我在这里给出完整的错误(调试控制台)消息:-
<project-path>Error:
uses-sdk:minSdkVersion 21 cannot be smaller than version 23 declared in library [:firebase_auth] J:\flutter_projects\messaging_app\build\firebase_auth\intermediates\merged_manifest\debug\AndroidManifest.xml as the library might be using APIs not available in 21
Suggestion: use a compatible library with a minSdk of at most 21,
or increase this project's minSdk version to at least 23,
or use tools:overrideLibrary="io.flutter.plugins.firebase.auth" 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 21 cannot be smaller than version 23 declared in library [:firebase_auth] J:\flutter_projects\messaging_app\build\firebase_auth\intermediates\merged_manifest\debug\AndroidManifest.xml as the library might be using APIs not available in 21
Suggestion: use a compatible library with a minSdk of at most 21,
or increase this project's minSdk version to at least 23,
or use tools:overrideLibrary="io.flutter.plugins.firebase.auth" to force usage (may lead to runtime failures)
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 4s
┌─ Flutter Fix ─────────────────────────────────────────────────────────────────────────────────┐
│ The plugin firebase_auth requires a higher Android SDK version. │
│ Fix this issue by adding the following to the file │
│ J:\flutter_projects\messaging_app\android\app\build.gradle: │
│ android { │
│ defaultConfig { │
│ minSdkVersion 23 │
│ } │
│ } │
│ │
│ Following this change, your app will not be available to users running Android SDKs below 23. │
│ Consider searching for a version of this plugin that supports these lower versions of the │
│ Android SDK instead. │
│ For more information, see: │
│ https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration │
└───────────────────────────────────────────────────────────────────────────────────────────────┘
Error: Gradle task assembleDebug failed with exit code 1
将错误消息中给定/推荐的代码粘贴到 gradle.build 后,它在文件中给出了错误,并且不会解决任何问题。我在 chatGpt 上看过,但它的解决方案似乎根本不起作用。
嘿CrazyFlutterDev
为什么会出现问题 -
在错误消息本身中说,插件 firebase-auth 要求您应用程序的 minSDK 应该为 23 ,因为该插件使用任何功能(意味着每个更新的 SDK 版本,您都会获得新的组件,即类、接口、方法),这些功能在SDK 版本低于 23(即本例中为 21)。
已找到解决方案 -
您应该只在构建文件中搜索 minSDK 并将其升级到 23,而不是复制粘贴整个内容,即 Flutter Fix Window 中编写的内容。