After running the Flutter project, I get this error. What can I do to solve it?
Error: The method 'setMockMessageHandler'
isn't defined for the class 'BasicMessageChannel<dynamic>'.
FAILURE: Build failed with an exception.
After running the Flutter project, I get this error. What can I do to solve it?
Error: The method 'setMockMessageHandler'
isn't defined for the class 'BasicMessageChannel<dynamic>'.
FAILURE: Build failed with an exception.
I have the same problem, I have tried all the above and did not help.
flutter pub upgrade
and flutter pub upgrade --major-versions
outputs this:
No dependencies changed.
1 package is discontinued.
76 packages have newer versions incompatible with dependency constraints.
Try flutter pub outdated
for more information.
No changes to pubspec.yaml!
The plugins advance_pdf_viewer, flutter_absolute_path, geocoder, google_api_headers, onesignal_flutter
use a deprecated version of the
Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if these plugins support the Android V2 embedding. Otherwise,
consider removing them since a future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding:
https://flutter.dev/go/android-plugin-migration.
I had the same problem today.
from what i could notice, this basically was a breaking change caused by transition of platform channel test interfaces to flutter_test package.
in my case, the problem was resolved just running the flutter pub upgrade
on a global terminal session.
see more details about the mentioned transition on referred release notes
} but this is just simple hack which is not recommended
Running across this problem after upgrading to Flutter 2.5.3 (from 2.2.3). The change outlined in the release notes broke several hundred tests since the mock method handlers were set in the global setUp()
for most tests.
As shown in the release notes, I replaced code like
MethodChannel('channelName')
.setMockMethodCallHandler((MethodCall methodCall) {});
with code using the default instance of TestDefaultBinaryMessenger
:
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(MethodChannel('channelName'), (MethodCall methodCall) {});
This change allowed me to keep all tests unchanged.
I had the same problem after update plugin's in AndroidStudio on Mac
did nothing for me, but
has solved the problem