【问题标题】:Flutter web release mode errors [closed]Flutter Web 发布模式错误 [关闭]
【发布时间】:2021-09-20 20:55:47
【问题描述】:

我有一个在 Flutter Web 上以调试模式正常运行的 Flutter 应用程序, 然后我使用此命令在发布和配置文件模式下运行相同的应用程序 flutter run -d chrome --release 它给出了一个白屏,我打开了 chrome 控制台,它给出了这个模棱两可的错误 看不懂:

zone.dart:1339 Uncaught FormatException: SyntaxError: Unexpected token < in JSON at position 0
    at Object.c (http://localhost:6282/main.dart.js:4084:3)
    at Object.bjN (http://localhost:6282/main.dart.js:6909:9)
    at WI.tW (http://localhost:6282/main.dart.js:49640:28)
    at WI.J (http://localhost:6282/main.dart.js:49642:29)
    at http://localhost:6282/main.dart.js:125497:12
    at bd3.a (http://localhost:6282/main.dart.js:5826:71)
    at bd3.$2 (http://localhost:6282/main.dart.js:46749:23)
    at bbV.$1 (http://localhost:6282/main.dart.js:46741:30)
    at a8F.rs (http://localhost:6282/main.dart.js:48088:42)
    at aWK.$0 (http://localhost:6282/main.dart.js:47231:11)

编辑1:颤振医生详细日志为:

[√] Flutter (Channel stable, 2.2.3, on Microsoft Windows [Version 10.0.19042.1055], locale en-US)
    • Flutter version 2.2.3 at C:\flutter
    • Framework revision f4abaa0735 (10 days ago), 2021-07-01 12:46:11 -0700
    • Engine revision 241c87ad80
    • Dart version 2.13.4

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at C:\Users\ASUS\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 4.1.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)

[√] VS Code (version 1.55.2)
    • VS Code at C:\Users\ASUS\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.21.0

[√] Connected device (3 available)
    • Redmi Note 8 Pro (mobile) • pns4zlqkivhu9psk • android-arm64  • Android 10 (API 29)
    • Chrome (web)              • chrome           • web-javascript • Google Chrome 91.0.4472.124
    • Edge (web)                • edge             • web-javascript • Microsoft Edge 86.0.622.38

! Doctor found issues in 1 category.

Edit2: 调试模式下的颤振应用程序在 chrome 控制台中给出了这些错误,但它可以正常工作:

GET https://apidev2.koutbo6.com/2.0/online_status/room/1-02162-0/ 401

GET https://dev.koutbo6.com/site_media/avatars/table_image/default/koutbo4.png 404

但是,它与图像有关,我认为这不是问题的原因。

【问题讨论】:

  • flutter doctor -v怎么样
  • 我已经收录了
  • chrome 网络选项卡中可能有什么? (HTML 而不是 JSON)
  • 我已经包含了调试模式的日志
  • 该错误并不含糊,它实际上是在告诉您,您期望的 JSON 响应不是 JSON,或者您的 HTML 响应无法解析为 JSON。

标签: flutter dart flutter-web


【解决方案1】:

经过很长时间的研究,我发现这个问题与一个名为time_machine的外部包有关,它导致这个问题只是它在网络平台中的初始化步骤。

【讨论】:

    猜你喜欢
    • 2020-12-12
    • 2019-06-07
    • 2021-06-24
    • 1970-01-01
    • 2020-04-08
    • 2021-10-01
    • 2023-02-04
    • 2021-05-26
    • 2021-02-08
    相关资源
    最近更新 更多