Sathya Molagoda
Sathya Molagoda

Reputation: 671

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

After updating my flutter project when I was going to run the application in the android studio, I got the following error.

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

I tried following steps but I was not able to fix this.

How can I fix this issue?

Upvotes: 2

Views: 9545

Answers (4)

Sharanya Kolhapure
Sharanya Kolhapure

Reputation: 1

Update the flutter toast version to latest fluttertoast version in dependencies in pubspec.yaml . It worked for me.

Upvotes: 0

GeekyChick
GeekyChick

Reputation: 37

I got the same error. Tried updating compileSdkVersion. Didn't work for me. This solved my problem.

  1. pubspec.yaml -->> pub upgrade
  2. Change fluttertoast version to latest
  3. Pub get
  4. Run...

Upvotes: -1

SefaUn
SefaUn

Reputation: 1220

I tried your solution but it does not work for me. My solution is update compileSdkVersion to 30 in my app/build.gradle.

Upvotes: 1

Sathya Molagoda
Sathya Molagoda

Reputation: 671

This was happened due to a pub cache conflict. The problem was fixed after executing the following command in the terminal.

  1. dart pub cache repair
  2. dart pub get
  3. dart pub upgrade

Upvotes: 7

Related Questions