出了什么问题:任务 ':fluttertoast:compileDebugKotlin' 执行失败

What went wrong: Execution failed for task ':fluttertoast:compileDebugKotlin'

在 android studio 运行 应用程序更新我的 flutter 项目后,出现以下错误。

e: C:\Users\user\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\fluttertoast-7.1.5\android\src\main\kotlin\io\github\ponnamkarthik\toast\fluttertoast\MethodCallHandlerImpl.kt: (16, 16): Redeclaration: MethodCallHandlerImpl
e: C:\Users\user\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\fluttertoast-7.1.6\android\src\main\kotlin\io\github\ponnamkarthik\toast\fluttertoast\MethodCallHandlerImpl.kt: (17, 16): Redeclaration: MethodCallHandlerImpl

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':fluttertoast:compileDebugKotlin'.
> Compilation error. See log for more details

* 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 52s
Exception: Gradle task assembleDebug failed with exit code 1

我尝试了以下步骤,但无法解决此问题。

我该如何解决这个问题?

这是由于发布缓存冲突造成的。在终端中执行以下命令后问题得到解决。

  1. dart pub 缓存修复
  2. 飞镖酒吧获得
  3. 飞镖酒吧升级

我尝试了您的解决方案,但它对我不起作用。我的解决方案是在 app/build.gradle.

中将 compileSdkVersion 更新为 30

我遇到了同样的错误。已尝试更新 compileSdkVersion。没有为我工作。这解决了我的问题。

  1. pubspec.yaml -->> 酒吧升级
  2. fluttertoast 版本更改为最新版本
  3. 酒吧获得
  4. 运行...

在 pubspec.yaml 的依赖项中将 flutter toast 版本更新为最新的 fluttertoast 版本。它对我有用。