我想在我的flutter项目中添加依赖项,因此我需要更新到新的flutter版本。当更新我得到以上错误。
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 {
^^^^^^^^^^^^^^^^^^^^^
首先试着做
flutter pub upgrade
如果不行,试试
flutter clean
然后
flutter pub upgrade --major-versions
以上两个命令应该可以解决错误,但仍然假设——major-version如果软件包的新版本与依赖约束不兼容,请尝试
flutter pub outdated
之后,它仍然不工作,然后升级你的kotlin版本在android/build.gradle
ext.kotlin_version = '1.5.10'
和minsdk并编译到最新版本。