gpt4 book ai didi

Flutter 为 Web 构建 - "Failed to compile application"

转载 作者:行者123 更新时间:2023-12-03 02:44:35 27 4
gpt4 key购买 nike

我已经为我的项目启用了 Web 支持,并且在运行后 flutter run -d chrome我收到以下错误:

Launching lib/main.dart on Chrome in debug mode...
Syncing files to device Chrome...
Compiler message:
../../flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in_web-0.8.3+1/lib/src/generated/gapiauth2.dart:26:3: Error: JS interop classes do not support non-external constructors.
Try annotating with `external`.
GoogleAuth.fakeConstructor$();
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in_web-0.8.3+1/lib/src/generated/gapiauth2.dart:216:3: Error: JS interop classes do not support non-external constructors.
Try annotating with `external`.
SigninOptionsBuilder.fakeConstructor$();
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in_web-0.8.3+1/lib/src/generated/gapi.dart:351:3: Error: JS interop classes do not support non-external constructors.
Try annotating with `external`.
HttpRequestPromise.fakeConstructor$();
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in_web-0.8.3+1/lib/src/generated/gapi.dart:378:3: Error: JS interop classes do not support non-external constructors.
Try annotating with `external`.
HttpRequest.fakeConstructor$() : super.fakeConstructor$();
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in_web-0.8.3+1/lib/src/generated/gapi.dart:402:3: Error: JS interop classes do not support non-external constructors.
Try annotating with `external`.
HttpBatch.fakeConstructor$();
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in_web-0.8.3+1/lib/src/generated/gapi.dart:440:3: Error: JS interop classes do not support non-external constructors.
Try annotating with `external`.
RpcRequest.fakeConstructor$();
^
Syncing files to device Chrome... 19,442ms (!)
Failed to compile application.
Tals-Macbook:matkonit talbarda$ flutter run -d chrome
Launching lib/main.dart on Chrome in debug mode...
Syncing files to device Chrome...
Compiler message:
../../flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in_web-0.8.3+1/lib/src/generated/gapiauth2.dart:26:3: Error: JS interop classes do not support non-external constructors.
Try annotating with `external`.
GoogleAuth.fakeConstructor$();
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in_web-0.8.3+1/lib/src/generated/gapiauth2.dart:216:3: Error: JS interop classes do not support non-external constructors.
Try annotating with `external`.
SigninOptionsBuilder.fakeConstructor$();
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in_web-0.8.3+1/lib/src/generated/gapi.dart:351:3: Error: JS interop classes do not support non-external constructors.
Try annotating with `external`.
HttpRequestPromise.fakeConstructor$();
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in_web-0.8.3+1/lib/src/generated/gapi.dart:378:3: Error: JS interop classes do not support non-external constructors.
Try annotating with `external`.
HttpRequest.fakeConstructor$() : super.fakeConstructor$();
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in_web-0.8.3+1/lib/src/generated/gapi.dart:402:3: Error: JS interop classes do not support non-external constructors.
Try annotating with `external`.
HttpBatch.fakeConstructor$();
^
../../flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in_web-0.8.3+1/lib/src/generated/gapi.dart:440:3: Error: JS interop classes do not support non-external constructors.
Try annotating with `external`.
RpcRequest.fakeConstructor$();
^
Syncing files to device Chrome... 17,899ms (!)
Failed to compile application.

我怎样才能解决这个问题?

最佳答案

我注意到这个问题已在 google_sign_in_web 0.9.0 中修复。因此,请更改 pubspec.yaml 文件中的版本。

google_sign_in_web: ^0.9.1

2020 年 4 月 20 日更新:如果您依赖 google_sign_in,请在 pubspec.yaml 文件中更改该版本。
google_sign_in: 4.4.3

前:
但是,当你像我一样并且依赖于 google_sign_in 时,那么你还有更多的东西需要改变......
如果您将 google_sign_in_web 更改为 0.9.0,并将 google_sign_in 的版本更改为 4.4.1,则检索包将失败:
Because ${your_project_name} depends on google_sign_in 4.4.1 which depends on google_sign_in_web ^0.8.2, google_sign_in_web ^0.8.2 is required.
So, because ${your_project_name} depends on google_sign_in_web ^0.9.0, version solving failed.
pub get failed (1; So, because ${your_project_name} depends on google_sign_in_web ^0.9.0, version solving failed.)

在这种情况下,您必须等待 google_sign_in 升级(我创建了拉取请求 https://github.com/flutter/plugins/pull/2647 ),或者暂时像我一样:

1) 从 https://github.com/flutter/plugins 克隆 flutter 插件
mkdir /src
cd /src
git clone https://github.com/flutter/plugins.git

2) 更改/src/plugins/plugins/packages/google_sign_in/google_sign_in/pubspec.yaml 中的文件 pubspec.yaml
  google_sign_in_web: ^0.9.0

3) 更改项目中的依赖项以指向更改后的 google_sign_in 版本,即
google_sign_in:
path: ../../flutter/plugins/packages/google_sign_in/google_sign_in
google_sign_in_web: ^0.9.0

关于Flutter 为 Web 构建 - "Failed to compile application",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60911568/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com