醫生總結(要查看所有詳細資訊,請運行 flutter doctor -v):
[√] Flutter(Channel stable, 2.5.0, on Microsoft Windows [Versi?3n 10.0.19042.1348],locale en-US)
[√] Android 工具鏈 - 為Android 設備(Android SDK 版本 30.0.0-rc2)
[√] Chrome - 為網路開發
[√] 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 時出現以下錯誤包: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
uj5u.com熱心網友回復:
在 Dart 2.16 中添加了Error.throwWithStackTrace(從 2022 年 2 月 8 日開始的 Flutter 版本 2.10)。
您應該:
- 將 Flutter 更新到 2.10:
flutter upgrade - 或者使用舊版本的沖突包:
firebase_messaging_platform_interface: 3.1.6
uj5u.com熱心網友回復:
我遇到了同樣的問題并為此找到了解決方法。
添加 firebase_messaging_platform_interface pubspeck.yaml:
dependency_overrides:
firebase_messaging_platform_interface: 3.1.6
uj5u.com熱心網友回復:
正如這篇文章中所建議的(如何解決任務':app:compileFlutterBuildDebug'的執行失敗),您應該嘗試在終端“Packages get | Pub get”中運行,然后再次構建專案
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/432517.html
標籤:扑 firebase-云消息传递
下一篇:使用Flutter動態加載資源
