任务 ':fluttertoast:compileDebugKotlin' 执行失败

M.K*_*lik 7 android gradle kotlin flutter

  1. 我试过 flutter clean
  2. flutter pub cache repair,
  3. 更改 fluttertoast 包的版本和版本,并删除它,
  4. 删除android/.gradle目录并重新构建。

没有任何效果。

Launching lib\main.dart on Redmi Note 4 in debug mode...
lib\main.dart:1
Parameter format not correct -
e: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\fluttertoast-7.1.8\android\src\main\kotlin\io\github\ponnamkarthik\toast\fluttertoast\MethodCallHandlerImpl.kt: (45, 84): Unresolved reference: R
e: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\fluttertoast-7.1.8\android\src\main\kotlin\io\github\ponnamkarthik\toast\fluttertoast\MethodCallHandlerImpl.kt: (70, 68): Unresolved reference: R
e: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\fluttertoast-7.1.8\android\src\main\kotlin\io\github\ponnamkarthik\toast\fluttertoast\MethodCallHandlerImpl.kt: (85, 64): Unresolved reference: R
2

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 39s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
Run Code Online (Sandbox Code Playgroud)

jon*_*jon 22

更新compileSdkVersion30我的app/build.gradle解决了这个问题,让我保持最新gradle这个。

旧答案:

我不知道为什么,但我能够通过回滚到

classpath 'com.android.tools.build:gradle:3.5.4'
Run Code Online (Sandbox Code Playgroud)

在我的顶级水平build.gradle