3

Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel'.

FAILURE: Build failed with an exception.

Any help would be appreciated

This didn't fixed it : flutter pub upgrade

Note : I don't want to do this (flutter pub upgrade --major-versions) as doing this breaks the entire project and introduces dozens of more errors and bug

Below is the complete error message:

* Running Gradle task 'assembleRelease'...
/E:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_platform_interface-2.2.0/lib/messages.dart:432:15: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel'.

  • 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/E:/src/flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart'). Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'. channel.setMockMessageHandler((dynamic message) async { ^^^^^^^^^^^^^^^^^^^^^ /E:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_platform_interface-2.2.0/lib/messages.dart:440:15: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel'.
  • 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/E:/src/flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart'). Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'. channel.setMockMessageHandler((dynamic message) async { ^^^^^^^^^^^^^^^^^^^^^ /E:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_platform_interface-2.2.0/lib/messages.dart:451:15: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel'.
  • 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/E:/src/flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart'). Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'. channel.setMockMessageHandler((dynamic message) async { ^^^^^^^^^^^^^^^^^^^^^ /E:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_platform_interface-2.2.0/lib/messages.dart:463:15: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel'.
  • 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/E:/src/flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart'). Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'. channel.setMockMessageHandler((dynamic message) async { ^^^^^^^^^^^^^^^^^^^^^ /E:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_platform_interface-2.2.0/lib/messages.dart:475:15: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel'.
  • 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/E:/src/flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart'). Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'. channel.setMockMessageHandler((dynamic message) async { ^^^^^^^^^^^^^^^^^^^^^ /E:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_platform_interface-2.2.0/lib/messages.dart:487:15: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel'.
  • 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/E:/src/flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart'). Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'. channel.setMockMessageHandler((dynamic message) async { ^^^^^^^^^^^^^^^^^^^^^ /E:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_platform_interface-2.2.0/lib/messages.dart:499:15: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel'.
  • 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/E:/src/flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart'). Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'. channel.setMockMessageHandler((dynamic message) async { ^^^^^^^^^^^^^^^^^^^^^ /E:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_platform_interface-2.2.0/lib/messages.dart:510:15: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel'.
  • 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/E:/src/flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart'). Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'. channel.setMockMessageHandler((dynamic message) async { ^^^^^^^^^^^^^^^^^^^^^ /E:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_platform_interface-2.2.0/lib/messages.dart:521:15: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel'.
  • 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/E:/src/flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart'). Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'. channel.setMockMessageHandler((dynamic message) async { ^^^^^^^^^^^^^^^^^^^^^ /E:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_platform_interface-2.2.0/lib/messages.dart:532:15: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel'.
  • 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/E:/src/flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart'). Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'. channel.setMockMessageHandler((dynamic message) async { ^^^^^^^^^^^^^^^^^^^^^ /E:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_platform_interface-2.2.0/lib/messages.dart:544:15: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel'.
  • 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/E:/src/flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart'). Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'. channel.setMockMessageHandler((dynamic message) async { ^^^^^^^^^^^^^^^^^^^^^ /E:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/wakelock_platform_interface-0.1.0+1/lib/messages.dart:96:17: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel'.
  • 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/E:/src/flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart'). Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'. channel.setMockMessageHandler(null); ^^^^^^^^^^^^^^^^^^^^^ /E:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/wakelock_platform_interface-0.1.0+1/lib/messages.dart:98:17: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel'.
  • 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/E:/src/flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart'). Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'. channel.setMockMessageHandler((dynamic message) async { ^^^^^^^^^^^^^^^^^^^^^ /E:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/wakelock_platform_interface-0.1.0+1/lib/messages.dart:111:17: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel'.
  • 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/E:/src/flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart'). Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'. channel.setMockMessageHandler(null); ^^^^^^^^^^^^^^^^^^^^^ /E:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/wakelock_platform_interface-0.1.0+1/lib/messages.dart:113:17: Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel'.
  • 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('/E:/src/flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart'). Try correcting the name to the name of an existing method, or defining a method named 'setMockMessageHandler'. channel.setMockMessageHandler((dynamic message) async { ^^^^^^^^^^^^^^^^^^^^^

FAILURE: Build failed with an exception.

  • Where: Script 'E:\src\flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1005

  • What went wrong: Execution failed for task ':app:compileFlutterBuildRelease'.

Process 'command 'E:\src\flutter\flutter\bin\flutter.bat'' finished with non-zero exit value 1

  • 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 1m 2s Running Gradle task 'assembleRelease'... 63.1s Gradle task assembleRelease failed with exit code 1 Process finished with exit code 1 *

ahmed
  • 421
  • 6
  • 13

4 Answers4

1

Ok so after days of trying to debug I finally fixed it, Turned out "setMockMessageHandler" was a method which was removed from the latest flutter release and one of my dependency was using it: You can add it back into the project by adding the following dependency into your flutter pubspec.yaml file:

pigeon: ^1.0.7
ahmed
  • 421
  • 6
  • 13
0

This issue occurs due to older project structure and newer version of a plugin that causes conflicts. You can either go with older version of the plugin that is causing the error. Or upgrade your project overall.

You can learn more here: https://flutter.dev/docs/development/packages-and-plugins/plugin-api-migration

ecm
  • 2,583
  • 4
  • 21
  • 29
Rashid Wassan
  • 664
  • 5
  • 13
0

If you wanna use old version of then try removing the ^ for every package and then specifying the version number that you used before.

Example:

From

device_info_plus: ^2.1.0

To

device_info_plus: 2.1.0

Why to do so? The caret sign is like range. If you have a higher version of the package then it'll be used if it doesn't have any breaking changes (I suspect that that has failed to see the breaking change here). Learn more about ^ it here

Shaan Mephobic
  • 1,148
  • 2
  • 7
  • 15
0

did you tried this?

flutter clean

flutter pub get

flutter pub cache repair

flutter pub upgrade
ViKi Vyas
  • 691
  • 5
  • 16