[√] Flutter(稳定通道,2.5.0,在Microsoft Windows [Version 10.0.19042.1348]上,区域设置为en-US)
[√] Android工具链-用于开发Android设备(Android SDK版本30.0.0-rc2)
[√] Chrome-用于Web开发
[√] Android Studio(版本3.6)
[√] VS Code(版本1.52.1)
[√] 连接的设备(可用3个)
我的pubsec.yaml仅包含:
firebase_messaging:^10.0.1
firebase_core:^1.2.1
flutter_local_notifications:^6.1.0
即使在全新的Flutter项目中,当我将import 'package:firebase_messaging/firebase_messaging.dart';添加到main.dart时,我遇到了以下问题:
/D:/Flutter/flutter_windows_2.5.0-stable/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging_platform_interface-3.2.0/lib/src/method_channel/utils/exception.dart:13:11: Error: Method not found: 'Error.throwWithStackTrace'.
Error.throwWithStackTrace(exception, stackTrace);
^^^^^^^^^^^^^^^^^^^
/D:/Flutter/flutter_windows_2.5.0-stable/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging_platform_interface-3.2.0/lib/src/method_channel/utils/exception.dart:16:9: Error: Method not found: 'Error.throwWithStackTrace'.
Error.throwWithStackTrace(
^^^^^^^^^^^^^^^^^^^
/D:/Flutter/flutter_windows_2.5.0-stable/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging_platform_interface-3.2.0/lib/src/method_channel/utils/exception.dart:11:7: Error: A non-null value must be returned since the return type 'Never' doesn't allow null.
Never convertPlatformException(Object exception, StackTrace stackTrace) {
^
FAILURE: Build failed with an exception.
* Where:
Script 'D:\Flutter\flutter_windows_2.5.0-stable\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1005
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'D:\Flutter\flutter_windows_2.5.0-stable\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 15s
Exception: Gradle task assembleDebug failed with exit code 1
firebase_messaging
依赖于firebase_messaging_platform_interface
,后者 刚刚 更新到了版本3.2.0
,现在依赖于 Flutter 2.10 中的 Dart 2.16。问题详情(也影响了riverpod
,所以非常相似)。如果升级到 Flutter 2.10 导致构建失败,这可能会有所帮助。 - Baker