我不能再运行 Flutter 项目了
Posted
技术标签:
【中文标题】我不能再运行 Flutter 项目了【英文标题】:I can't run a Flutter project anymore 【发布时间】:2021-06-02 00:22:13 【问题描述】:昨天我最后一次在我的 Flutter 项目上工作。今天我只启动了 android Studio 并尝试启动我的项目,我收到了一条错误消息。我尝试了一切,我还检查了是否有一些更新等。
我能做些什么来解决这个问题?
这是错误信息:
[+13326 ms] C:\Users\******\AndroidStudioProjects\PROJECTNAME\android\app\src\debug\AndroidManifest.xml Error:
[ +1 ms] uses-sdk:minSdkVersion 16 cannot be smaller than version 23 declared in library [:audioplayers] C:\Users\******\AndroidStudioProjects\PROJECTNAME\build\audioplayers\intermediates\library_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 23,
[ ] or use tools:overrideLibrary="xyz.luan.audioplayers" to force usage (may lead to runtime failures)
[ ] FAILURE: Build failed with an exception.
[ ] * What went wrong:
[ ] Execution failed for task ':app:processDebugManifest'.
[ ] > Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 23 declared in library [:audioplayers] C:\Users\******\AndroidStudioProjects\PROJECTNAME\build\audioplayers\intermediates\library_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 23,
[ ] or use tools:overrideLibrary="xyz.luan.audioplayers" 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 13s
["event":"app.progress","params":"appId":"ab743200-5f09-4853-ae95-0b0cb729d0f0","id":"0","progressId":null,"finished":true]
[ +351 ms] Exception: Gradle task assembleDebug failed with exit code 1
[ +2 ms]
#0 throwToolExit (package:flutter_tools/src/base/common.dart:14:3)
#1 RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:474:9)
<asynchronous suspension>
#2 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:977:18)
#3 _rootRunUnary (dart:async/zone.dart:1198:47)
#4 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#5 _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
#6 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
#7 Future._propagateToListeners (dart:async/future_impl.dart:725:32)
#8 Future._completeWithValue (dart:async/future_impl.dart:529:5)
#9 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)
#10 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)
#11 RunCommand.usageValues (package:flutter_tools/src/commands/run.dart)
#12 _rootRunUnary (dart:async/zone.dart:1198:47)
#13 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#14 _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
#15 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
#16 Future._propagateToListeners (dart:async/future_impl.dart:725:32)
#17 Future._completeWithValue (dart:async/future_impl.dart:529:5)
#18 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)
#19 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)
#20 AndroidDevice.isLocalEmulator (package:flutter_tools/src/android/android_device.dart)
#21 _rootRunUnary (dart:async/zone.dart:1198:47)
#22 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#23 _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
#24 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
#25 Future._propagateToListeners (dart:async/future_impl.dart:725:32)
#26 Future._completeWithValue (dart:async/future_impl.dart:529:5)
#27 Future._asyncCompleteWithValue.<anonymous closure> (dart:async/future_impl.dart:567:7)
#28 _rootRun (dart:async/zone.dart:1190:13)
#29 _CustomZone.run (dart:async/zone.dart:1093:19)
#30 _CustomZone.runGuarded (dart:async/zone.dart:997:7)
#31 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
#32 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#33 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#34 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#35 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5)
【问题讨论】:
【参考方案1】:minSdkVersion 16 cannot be smaller than version 23
您使用的其中一个插件 (xyz.luan.audioplayers
) 与 API23 以下的 android 版本不兼容。您需要将项目的最低 SDK 版本设置为 23 或更高版本。
转到项目中的android
文件夹并打开app
文件夹,然后打开build.gradle
文件。
在该文件中,在defaultConfig
下编辑以下行
minSdkVersion 23
【讨论】:
【参考方案2】:您需要仔细阅读official document。如前所述,使用<uses-sdk tools:overrideLibrary="xyz.luan.audioplayers"/>
配置您的build.gradle
文件。
Gradle 构建失败
为了支持 playBytes 方法,这对使用 API >= 23 功能有硬性要求,并且您的构建可能会失败,具体取决于您的最低 sdk 目标。要覆盖它,您需要将
添加到您的 build.gradle
【讨论】:
以上是关于我不能再运行 Flutter 项目了的主要内容,如果未能解决你的问题,请参考以下文章
为啥 Flutter 应用程序不能使用命令 flutter run -d chrome 在 chrome 上运行
Flutter 运行和 ipa - Mac M1 - #import <Flutter/Flutter.h>
Flutter:升级 Flutter 和 Channel 后无法再构建应用程序