“ flutter pub get”无法获取依赖项插件

时间:2020-03-29 19:15:12

标签: android flutter dart flutter-packages

我一直在尝试获取Windows上Flutter项目的依赖关系,但是这花费了很长时间,并且过了一会儿,它在“消息”栏中显示了此错误。

Running "flutter pub get" in badhan_blood_bank...               
OS Error: The semaphore timeout period has expired.

, errno = 121, address = storage.googleapis.com, port = 53515

pub get failed (server unavailable) -- attempting retry 1 in 1 second...

我正在尝试以某种方式解决此问题,但未能解决。 我正在进行抖动清理,抖动升级并最终重启android studio时会发生同样的问题。

在将url_launcher添加到项目中的依赖项之前,它运行良好。

这是我的pubspec.yaml文件:

version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^0.1.2
  firebase_auth: ^0.15.5+2
  flutter_facebook_login: ^3.0.0
  flutter_icons: ^1.0.0+1
  flutter_spinkit: ^4.1.2
  firebase_database: ^3.1.3
  google_maps_flutter: ^0.5.25
  geolocator: ^5.3.0
  intl: ^0.16.1
  curved_navigation_bar: ^0.3.2
  fluttertoast: ^4.0.1
  url_launcher: ^5.4.2



dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:
  uses-material-design: true

  assets:
  - images/


运行“ flutter pub get --verbose”后显示:

[  +27 ms] executing: [C:\src\flutter\flutter\] git -c log.showSignature=false log -n 1 --pretty=format:%H
[  +64 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] 0b8abb4724aa590dd0f429683339b1e045a1594d
[        ] executing: [C:\src\flutter\flutter\] git describe --match v*.*.* --first-parent --long --tags
[  +56 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[        ] v1.12.13+hotfix.8-0-g0b8abb472
[   +7 ms] executing: [C:\src\flutter\flutter\] git rev-parse --abbrev-ref --symbolic @{u}
[  +41 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/stable
[        ] executing: [C:\src\flutter\flutter\] git ls-remote --get-url origin
[  +38 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[  +77 ms] executing: [C:\src\flutter\flutter\] git rev-parse --abbrev-ref HEAD
[  +41 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] stable
[  +48 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +4 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +130 ms] Running "flutter pub get" in badhan_blood_bank...
[   +5 ms] Using C:\src\flutter\flutter\.pub-cache for the pub cache.
[   +1 ms] executing: [D:\@@MyWorks\mahmud\Badhan Blood Bank\badhan_blood_bank\] C:\src\flutter\flutter\bin\cache\dart-sdk\bin\pub.bat --verbose get
--no-precompile
[ +157 ms] FINE: Pub 2.7.0
[   +3 ms] IO  : Spawning "cmd /c ver" in D:\@@MyWorks\mahmud\Badhan Blood Bank\badhan_blood_bank\.
[   +7 ms] IO  : Finished ver. Exit code 0.
[   +1 ms]     | stdout:
[        ]     | | 
[   +1 ms]     | | Microsoft Windows [Version 10.0.18362.720]
[   +1 ms]     | Nothing output on stderr.
[ +102 ms] MSG : Resolving dependencies...
[   +9 ms] SLVR: fact: badhanbloodbank is 1.0.0+1
[   +5 ms] SLVR: derived: badhanbloodbank
[  +61 ms] SLVR: fact: badhanbloodbank depends on flutter any from sdk
[   +1 ms] SLVR: fact: badhanbloodbank depends on cupertino_icons ^0.1.2
[   +1 ms] SLVR: fact: badhanbloodbank depends on firebase_auth ^0.15.5+2
[   +1 ms] SLVR: fact: badhanbloodbank depends on flutter_facebook_login ^3.0.0
[   +1 ms] SLVR: fact: badhanbloodbank depends on flutter_icons ^1.0.0+1
[   +1 ms] SLVR: fact: badhanbloodbank depends on flutter_spinkit ^4.1.2
[        ] SLVR: fact: badhanbloodbank depends on firebase_database ^3.1.3
[        ] SLVR: fact: badhanbloodbank depends on google_maps_flutter ^0.5.25
[        ] SLVR: fact: badhanbloodbank depends on geolocator ^5.3.0
[        ] SLVR: fact: badhanbloodbank depends on intl ^0.16.1
[        ] SLVR: fact: badhanbloodbank depends on curved_navigation_bar ^0.3.2
[        ] SLVR: fact: badhanbloodbank depends on fluttertoast ^4.0.1
[        ] SLVR: fact: badhanbloodbank depends on url_launcher ^5.4.2
[        ] SLVR: fact: badhanbloodbank depends on flutter_test any from sdk
[        ] SLVR:   selecting badhanbloodbank
[        ] SLVR:   derived: flutter_test any from sdk
[        ] SLVR:   derived: url_launcher ^5.4.2
[   +1 ms] SLVR:   derived: fluttertoast ^4.0.1
[   +1 ms] SLVR:   derived: curved_navigation_bar ^0.3.2
[        ] SLVR:   derived: intl ^0.16.1
[   +1 ms] SLVR:   derived: geolocator ^5.3.0
[   +1 ms] SLVR:   derived: google_maps_flutter ^0.5.25
[   +1 ms] SLVR:   derived: firebase_database ^3.1.3
[        ] SLVR:   derived: flutter_spinkit ^4.1.2
[        ] SLVR:   derived: flutter_icons ^1.0.0+1
[        ] SLVR:   derived: flutter_facebook_login ^3.0.0
[        ] SLVR:   derived: firebase_auth ^0.15.5+2
[        ] SLVR:   derived: cupertino_icons ^0.1.2
[        ] SLVR:   derived: flutter any from sdk
[        ] IO  : Get versions from https://pub.dartlang.org/api/packages/url_launcher.
[   +9 ms] IO  : HTTP GET https://pub.dartlang.org/api/packages/url_launcher
[   +2 ms]     | Accept: application/vnd.pub.v2+json
[   +1 ms]     | X-Pub-OS: windows
[        ]     | X-Pub-Command: get
[        ]     | X-Pub-Session-ID: 795584D9-523C-4575-B686-2D496C324C5B
[        ]     | X-Pub-Environment: flutter_cli:get
[   +1 ms]     | X-Pub-Reason: direct
[        ]     | user-agent: Dart pub 2.7.0
[ +934 ms] IO  : HTTP response 200 OK for GET https://pub.dartlang.org/api/packages/url_launcher
[   +5 ms]     | took 0:00:00.938247
[   +2 ms]     | transfer-encoding: chunked
[   +2 ms]     | date: Sun, 29 Mar 2020 19:47:07 GMT
[   +2 ms]     | content-encoding: gzip
[   +2 ms]     | vary: Accept-Encoding
[   +3 ms]     | strict-transport-security: max-age=31536000; preload
[   +3 ms]     | via: 1.1 google
[   +2 ms]     | content-type: application/json
[   +2 ms]     | x-frame-options: SAMEORIGIN
[   +2 ms]     | x-xss-protection: 1; mode=block
[   +2 ms]     | x-content-type-options: nosniff
[   +2 ms]     | server: dart:io with Shelf
[  +66 ms] SLVR:   fact: flutter_test 0.0.0 from sdk depends on flutter any from sdk
[   +1 ms] SLVR:   fact: flutter_test 0.0.0 from sdk depends on test_api 0.2.11
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on path 1.6.4
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on image 2.1.4
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on quiver 2.0.5
[   +1 ms] SLVR:   fact: flutter_test 0.0.0 from sdk depends on stack_trace 1.9.3
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on vector_math 2.0.8
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on archive 2.0.11
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on args 1.5.2
[   +1 ms] SLVR:   fact: flutter_test 0.0.0 from sdk depends on async 2.4.0
[   +1 ms] SLVR:   fact: flutter_test 0.0.0 from sdk depends on boolean_selector 1.0.5
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on charcode 1.1.2
[   +1 ms] SLVR:   fact: flutter_test 0.0.0 from sdk depends on collection 1.14.11
[   +1 ms] SLVR:   fact: flutter_test 0.0.0 from sdk depends on convert 2.1.1
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on crypto 2.1.3
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on matcher 0.12.6
[   +2 ms] SLVR:   fact: flutter_test 0.0.0 from sdk depends on meta 1.1.8
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on pedantic 1.8.0+1
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on petitparser 2.4.0
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on source_span 1.5.5
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on stream_channel 2.0.0
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on string_scanner 1.0.5
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on term_glyph 1.1.0
[        ] SLVR:   fact: flutter_test 0.0.0 from sdk depends on typed_data 1.1.6
[   +1 ms] SLVR:   fact: flutter_test 0.0.0 from sdk depends on xml 3.5.0
[        ] SLVR:     selecting flutter_test 0.0.0 from sdk
[        ] SLVR:     derived: xml 3.5.0
[        ] SLVR:     derived: typed_data 1.1.6
[   +1 ms] SLVR:     derived: term_glyph 1.1.0
[        ] SLVR:     derived: string_scanner 1.0.5
[        ] SLVR:     derived: stream_channel 2.0.0
[   +2 ms] SLVR:     derived: source_span 1.5.5
[        ] SLVR:     derived: petitparser 2.4.0
[        ] SLVR:     derived: pedantic 1.8.0+1
[        ] SLVR:     derived: meta 1.1.8
[   +3 ms] SLVR:     derived: matcher 0.12.6
[        ] SLVR:     derived: crypto 2.1.3
[        ] SLVR:     derived: convert 2.1.1
[   +1 ms] SLVR:     derived: collection 1.14.11
[        ] SLVR:     derived: charcode 1.1.2
[        ] SLVR:     derived: boolean_selector 1.0.5
[        ] SLVR:     derived: async 2.4.0
[   +1 ms] SLVR:     derived: args 1.5.2
[   +4 ms] SLVR:     derived: archive 2.0.11
[   +1 ms] SLVR:     derived: vector_math 2.0.8
[   +4 ms] SLVR:     derived: stack_trace 1.9.3
[   +1 ms] SLVR:     derived: quiver 2.0.5
[        ] SLVR:     derived: image 2.1.4
[   +1 ms] SLVR:     derived: path 1.6.4
[   +1 ms] SLVR:     derived: test_api 0.2.11
[   +1 ms] SLVR:     fact: url_launcher >=3.0.0 depends on flutter any from sdk
[        ] SLVR:     fact: url_launcher >=5.4.0 depends on url_launcher_macos ^0.0.1
[   +1 ms] SLVR:     fact: url_launcher >=5.4.1 depends on url_launcher_platform_interface ^1.0.4
[   +1 ms] SLVR:     fact: url_launcher >=5.3.0 depends on url_launcher_web ^0.1.0+1
[   +1 ms] SLVR:       selecting url_launcher 5.4.2
[        ] SLVR:       derived: url_launcher_web ^0.1.0+1
[        ] SLVR:       derived: url_launcher_platform_interface ^1.0.4
[        ] SLVR:       derived: url_launcher_macos ^0.0.1
[   +1 ms] IO  : Get versions from https://pub.dartlang.org/api/packages/url_launcher_web.
[   +1 ms] IO  : HTTP GET https://pub.dartlang.org/api/packages/url_launcher_web
[        ]     | Accept: application/vnd.pub.v2+json
[        ]     | X-Pub-OS: windows
[        ]     | X-Pub-Command: get
[        ]     | X-Pub-Session-ID: 795584D9-523C-4575-B686-2D496C324C5B
[        ]     | X-Pub-Environment: flutter_cli:get
[        ]     | user-agent: Dart pub 2.7.0
[ +429 ms] IO  : HTTP response 200 OK for GET https://pub.dartlang.org/api/packages/url_launcher_web

问题是什么以及如何解决?

4 个答案:

答案 0 :(得分:8)

从昨天开始,孟加拉国的storage.googleapis.com出了点问题。

首先,我认为这可能与Google基础架构有关。
但是,一段时间后,我意识到这是BTCL的问题。

要解决此问题,您可以使用VPN工具并重新运行您的项目。
我使用Hotspot Sheild VPN之后,一切都很好。

请记住,免费版本限制为500 MB/Day

我希望这也对您有用。

答案 1 :(得分:2)

  1. 更新Flutter无效
  2. 重新启动PC无效
  3. 创建新项目并运行pub get无效。

如果您来自孟加拉国,那么唯一的解决方案是暂时使用VPN。 BTCL存在一些网络问题,这是导致问题的原因。

答案 2 :(得分:1)

'flutter pub get'尝试获取您在pubspec.yaml中声明的插件,默认情况下,它向pub.dev或https://pub.dartlang.org发出GET请求。因此,如果https://pub.dartlang.org或storage.googleapis.com被您的isp或公司的防火墙阻止,则您将无法完成软件包,因此也无法构建Flutter项目。 与使用VPN相比,我更喜欢使用镜像存储库。您可以使用如下所述的镜像链接简单地更改或设置两个环境变量。之后,“ flutter pub get”命令将尝试从特定的镜像链接获取软件包。变量和链接是- * PUB_HOSTED_URL = https://pub.flutter-io.cn * FLUTTER_STORAGE_BASE_URL = https://storage.flutter-io.cn

对于Windows,请在cmd中使用以下命令在您的项目环境中设置变量:

set PUB_HOSTED_URL=https://pub.flutter-io.cn
set FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

确保在cmd的项目目录中应用这些命令,并使用该特定cmd的“ flutter pub get”。 您可以通过应用以下命令检查变量是否已设置:

echo %PUB_HOSTED_URL% 

输出应该是您刚刚设置的URL。

这些变量仅在此环境中设置,并且在关闭此终端时将被清除。因此,对于Windows,如果您在系统用户环境中设置这些变量,则可以随时使用“ flutter pub get”并从china镜像站点获取软件包。

对于Mac,像这样导出bash_profile中的变量:

 export PUB_HOSTED_URL=https://pub.flutter-io.cn
 export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

在此之后,您应该能够成功应用flutter pub get。 (记住在设置变量后获取bash_profile的来源)

所有这些之后,如果仍然无法获得软件包: *从您的项目中删除pubspec.lock文件。 *重新启动您的PC。 *通过使用echo命令检查是否正确设置了PUB_HOSTED_URL和FLUTTER_STORAGE_BASE_URL环境变量。

如果设置了这些变量,则flutter sdk将尝试从您通过此变量设置的镜像站点中获取软件包。如果工作空间环境中不存在这些变量,则flutter sdk将尝试使用前面提到的默认URL来获取软件包。

N.B:当它对我不起作用时,我感到沮丧并重新安装了flutter sdk,然后在我的环境中设置了这些变量,并从项目中删除了pubspec.lock文件。还有尤里卡!它为我工作。之后,通过一些挖掘,我发现我不必再次卸载并安装flutter。

希望您现在可以在不使用vpn和其他任何东西的情况下获取软件包。 祝你好运。

答案 3 :(得分:0)

只需从IDE中关闭项目,然后重新打开即可。然后运行pub get。