簡體   English   中英

錯誤:必須返回非空值,因為返回類型“Never”不允許 null。Never convertPlatformException(對象異常,StackTrace

[英]Error: A non-null value must be returned since the return type 'Never' doesn't allow null. Never convertPlatformException(Object exception, StackTrace

我正在嘗試將 Firebase Crashlytics 集成到 Flutter 應用程序(反例代碼)中。 即使從 Flutter 2.2.1 升級到 Flutter 3.0.0 后,我仍收到上述錯誤。

調試控制台 Output:

/C:/src/fl/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_crashlytics_platform_interface-3.2.0/lib/src/method_channel/utils/exception.dart:13:11: Error: Method not found: 'Error.throwWithStackTrace'.
    Error.throwWithStackTrace(exception, stackTrace);
          ^^^^^^^^^^^^^^^^^^^

/C:/src/fl/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_crashlytics_platform_interface-3.2.0/lib/src/method_channel/utils/exception.dart:16:9: Error: Method not found: 'Error.throwWithStackTrace'.
  Error.throwWithStackTrace(
        ^^^^^^^^^^^^^^^^^^^
/C:/src/fl/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_crashlytics_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) {
      ^
3

FAILURE: Build failed with an exception.

* Where:
Script 'C:\src\fl\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1005

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\fl\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 16s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

Flutter 醫生:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.0.0, on Microsoft Windows [Version 10.0.22000.675], locale en-IN)
[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[√] Chrome - develop for the web
[X] Visual Studio - develop for Windows
    X Visual Studio not installed; this is necessary for Windows development.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2021.2)
[√] VS Code (version 1.67.2)
[√] Connected device (4 available)
[√] HTTP Host Availability

! Doctor found issues in 1 category.

請建議如何解決這個問題。 謝謝。

嘗試將您的版本庫更新為firebase_crashlytics: ^2.8.0

檢查並更新您的 sdk 以使用sdk: ">=2.17.1 <3.0.0" in pubspec.yaml

environment:
  sdk: ">=2.17.1 <3.0.0"

然后flutter pub upgrade > flutter clean > flutter pub get

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM