ahmed
ahmed

Reputation: 527

Can't build flutter project when opening it after a long time

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'.

FAILURE: Build failed with an exception.

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

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 *

Upvotes: 3

Views: 4081

Answers (4)

ViKi Vyas
ViKi Vyas

Reputation: 741

did you tried this?

flutter clean

flutter pub get

flutter pub cache repair

flutter pub upgrade

Upvotes: 0

ahmed
ahmed

Reputation: 527

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

Upvotes: 1

Rashid Wassan
Rashid Wassan

Reputation: 764

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

Upvotes: 0

Shaan Mephobic
Shaan Mephobic

Reputation: 1216

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

Upvotes: 0

Related Questions