1

I wanted to add dependences in my flutter project for that I need to update to new flutter version. While updating I am getting above error.

Running Gradle task 'assembleDebug'...
../../../../../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<dynamic>'.
 - 'BasicMessageChannel' is from 'package:flutter/src/services/platform_channel.dart' ('../../../../../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 {
              ^^^^^^^^^^^^^^^^^^^^^
  • 1
    Refer the answer in https://stackoverflow.com/questions/67915153/the-method-setmockmessagehandler-isnt-defined-for-the-class-basicmessagechan – Aysha Hamna Oct 07 '21 at 07:21
  • I have followed those commands, but I am unable to add new dependencies without upgrading, when I upgrade that it shows exit 0, when I try to run the code in my phone it was again showing the same error. I am using flutter 2.5.2, When I use flutter 2.2.2 my code runs in it, but I am unable to add new dependencies without flutter upgrading. – Kiranmayi Jagan Oct 07 '21 at 07:57
  • @KiranmayiJagan have you found the solution ? – ᴅ ᴇ ʙ ᴊ ᴇᴇ ᴛ Apr 14 '22 at 06:38

1 Answers1

0

Firstly try to do

flutter pub upgrade

if this does not work try

flutter clean

then

flutter pub upgrade --major-versions

The above two commands should solve the errors but still suppose this --major-version commands gives you this error packages have newer versions incompatible with dependency constraints then try

flutter pub outdated

and after this still, it not working then upgrade your kotlin version in android/build.gradle

ext.kotlin_version = '1.5.10'

and minsdk and compilesdk version to the latest.