Flutter错误: uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared

前言

今天要做蓝牙通信的功能,我使用了flutter_reactive_ble这个库,但是在运行的时候发现一下错误

Launching lib/main.dart on AQM AL10 in debug mode...

/Users/macbook/Desktop/test/flutter/my_app/android/app/src/debug/AndroidManifest.xml Error:

``uses-sdk:minSdkVersion ``16 cannot be smaller than version ``21 declared in library [:reactive_ble_mobile] /Users/macbook/Desktop/test/flutter/my_app/build/reactive_ble_mobile/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 ``21``,

``or use tools:overrideLibrary=``"com.signify.hue.flutterreactiveble" 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 ``21 declared in library [:reactive_ble_mobile] /Users/macbook/Desktop/test/flutter/my_app/build/reactive_ble_mobile/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 ``21``,

``or use tools:overrideLibrary=``"com.signify.hue.flutterreactiveble" 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 reactive_ble_mobile requires a higher Android SDK version. │

│ Fix ``this issue by adding the following to the file │

│ /Users/macbook/Desktop/test/flutter/my_app/android/app/build.gradle: │

│ android { │

│ defaultConfig { │

│ minSdkVersion ``21

│ } │

│ } │

│ │

│ Note that your app won't be available to users running Android SDKs below ``21``. │

│ Alternatively, ``try to find a version of ``this plugin that supports these lower versions of the │

│ Android SDK. │

│ For more information, see: │

│ https:``//docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration │

└───────────────────────────────────────────────────────────────────────────────────────────────┘

Exception: Gradle task assembleDebug failed with exit code ``1

Exited

问题原因

自己项目的minSdkVersion比三方SDK的的minSdkVersion低,即版本不一致导致的。

解决办法

方法一

前往项目------>android------>app------>build.gradle文件搜索defaultConfig,将minSdkVersion修改成固定值即可

方法二

进入flutter环境安装目录/packages/flutter_tools/gradle(这里的flutter是环境变量中配置的flutter路径),搜索minSdkVersion,将值改为需求的版本即可(我这里改成21)

相关推荐
愚者Pro4 小时前
切换本地 Flutter SDK 版本
flutter
TT_Close5 小时前
别再复制旧 Flutter 工程了,真正拖慢你的不是业务代码
flutter·npm·visual studio code
风华圆舞6 小时前
鸿蒙 + Flutter 下 AI 助手为什么要支持流式输出
人工智能·flutter·harmonyos
风华圆舞10 小时前
鸿蒙 + Flutter 下 AI 页面的状态协同设计
人工智能·flutter·harmonyos
风华圆舞12 小时前
鸿蒙语音播报功能 的 Flutter 侧封装思路
flutter·华为·harmonyos
brycegao32112 小时前
Flutter 国际化富文本解决方案:基于双层占位符的轻量化图文混排方案
flutter·国际化·i18n·富文本·rtl·移动端工程架构
风华圆舞12 小时前
鸿蒙 + Flutter 下美食探索场景为什么 AI 推荐比传统搜索更自然
flutter·harmonyos·美食
MemoriKu13 小时前
Flutter 相册 APP 收尾优化实战:未分析任务横幅持久隐藏与标签回归测试补强
大数据·人工智能·flutter·elasticsearch·机器学习·搜索引擎·重构
风华圆舞14 小时前
鸿蒙 + Flutter 如何把 AI 助手嵌进应用页面里——以食界探味为
人工智能·flutter·harmonyos
风华圆舞15 小时前
鸿蒙 + Flutter 下如何管理 AI 会话——AgentService 设计解析
人工智能·flutter·harmonyos