【错误记录】命令行创建 Flutter 应用报错 pub get failed (server unavailable) -- attempting retry 1 in 1 second...

文章目录

  • 一、 报错信息
  • 二、 解决方案



官方推荐的中国镜像 : https://flutter.dev/community/china

问题原因找到 , 上海交通大学的 Flutter 镜像失效导致 , 或者暂时性失效 ; ( 反正今天是没用上 )

Shanghai Jiaotong University Linux User Group
FLUTTER_STORAGE_BASE_URL: https://mirrors.sjtug.sjtu.edu.cn/
PUB_HOSTED_URL: https://dart-pub.mirrors.sjtug.sjtu.edu.cn/

使用官方镜像后 , 执行 flutter create flutter_cmd 命令创建应用成功 ;

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

镜像需要设置到环境变量中 ;





一、 报错信息



使用命令行创建 Flutter 应用 , 命令如下 :

flutter create flutter_cmd

创建一个 Flutter 应用 , 应用名称是 flutter_cmd ;


报错信息 :

D:\002_Project\002_Android_Learn\Flutter_Cmd>flutter create flutter_cmd
Creating project flutter_cmd... androidx: true
  flutter_cmd\.gitignore (created)
  flutter_cmd\.idea\libraries\Dart_SDK.xml (created)
  flutter_cmd\.idea\libraries\Flutter_for_Android.xml (created)
  flutter_cmd\.idea\libraries\KotlinJavaRuntime.xml (created)
  flutter_cmd\.idea\modules.xml (created)
  flutter_cmd\.idea\runConfigurations\main_dart.xml (created)
  flutter_cmd\.idea\workspace.xml (created)
  flutter_cmd\.metadata (created)
  flutter_cmd\android\app\build.gradle (created)
  flutter_cmd\android\app\src\main\kotlin\com\example\flutter_cmd\MainActivity.kt (created)
  flutter_cmd\android\build.gradle (created)
  flutter_cmd\android\flutter_cmd_android.iml (created)
  flutter_cmd\android\.gitignore (created)
  flutter_cmd\android\app\src\debug\AndroidManifest.xml (created)
  flutter_cmd\android\app\src\main\AndroidManifest.xml (created)
  flutter_cmd\android\app\src\main\res\drawable\launch_background.xml (created)
  flutter_cmd\android\app\src\main\res\mipmap-hdpi\ic_launcher.png (created)
  flutter_cmd\android\app\src\main\res\mipmap-mdpi\ic_launcher.png (created)
  flutter_cmd\android\app\src\main\res\mipmap-xhdpi\ic_launcher.png (created)
  flutter_cmd\android\app\src\main\res\mipmap-xxhdpi\ic_launcher.png (created)
  flutter_cmd\android\app\src\main\res\mipmap-xxxhdpi\ic_launcher.png (created)
  flutter_cmd\android\app\src\main\res\values\styles.xml (created)
  flutter_cmd\android\app\src\profile\AndroidManifest.xml (created)
  flutter_cmd\android\gradle\wrapper\gradle-wrapper.properties (created)
  flutter_cmd\android\gradle.properties (created)
  flutter_cmd\android\settings.gradle (created)
  flutter_cmd\ios\Runner\AppDelegate.swift (created)
  flutter_cmd\ios\Runner\Runner-Bridging-Header.h (created)
  flutter_cmd\ios\Runner.xcodeproj\project.pbxproj (created)
  flutter_cmd\ios\Runner.xcodeproj\xcshareddata\xcschemes\Runner.xcscheme (created)
  flutter_cmd\ios\.gitignore (created)
  flutter_cmd\ios\Flutter\AppFrameworkInfo.plist (created)
  flutter_cmd\ios\Flutter\Debug.xcconfig (created)
  flutter_cmd\ios\Flutter\Release.xcconfig (created)
  flutter_cmd\ios\Runner\Assets.xcassets\AppIcon.appiconset\Contents.json (created)
  flutter_cmd\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-1024x1024@1x.png (created)
  flutter_cmd\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@1x.png (created)
  flutter_cmd\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@2x.png (created)
  flutter_cmd\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@3x.png (created)
  flutter_cmd\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@1x.png (created)
  flutter_cmd\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@2x.png (created)
  flutter_cmd\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@3x.png (created)
  flutter_cmd\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@1x.png (created)
  flutter_cmd\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@2x.png (created)
  flutter_cmd\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@3x.png (created)
  flutter_cmd\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-60x60@2x.png (created)
  flutter_cmd\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-60x60@3x.png (created)
  flutter_cmd\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-76x76@1x.png (created)
  flutter_cmd\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-76x76@2x.png (created)
  flutter_cmd\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-83.5x83.5@2x.png (created)
  flutter_cmd\ios\Runner\Assets.xcassets\LaunchImage.imageset\Contents.json (created)
  flutter_cmd\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage.png (created)
  flutter_cmd\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage@2x.png (created)
  flutter_cmd\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage@3x.png (created)
  flutter_cmd\ios\Runner\Assets.xcassets\LaunchImage.imageset\README.md (created)
  flutter_cmd\ios\Runner\Base.lproj\LaunchScreen.storyboard (created)
  flutter_cmd\ios\Runner\Base.lproj\Main.storyboard (created)
  flutter_cmd\ios\Runner\Info.plist (created)
  flutter_cmd\ios\Runner.xcodeproj\project.xcworkspace\contents.xcworkspacedata (created)
  flutter_cmd\ios\Runner.xcworkspace\contents.xcworkspacedata (created)
  flutter_cmd\lib\main.dart (created)
  flutter_cmd\flutter_cmd.iml (created)
  flutter_cmd\pubspec.yaml (created)
  flutter_cmd\README.md (created)
  flutter_cmd\test\widget_test.dart (created)
Because flutter_cmd depends on cupertino_icons any which doesn't exist (could not find package cupertino_icons at https://storage.flutter-io.cn), version solving failed.
pub get failed (server unavailable) -- attempting retry 1 in 1 second...
Because flutter_cmd depends on cupertino_icons any which doesn't exist (could not find package cupertino_icons at https://storage.flutter-io.cn), version solving failed.
pub get failed (server unavailable) -- attempting retry 2 in 2 seconds...
Because flutter_cmd depends on cupertino_icons any which doesn't exist (could not find package cupertino_icons at https://storage.flutter-io.cn), version solving failed.
pub get failed (server unavailable) -- attempting retry 3 in 4 seconds...
Because flutter_cmd depends on cupertino_icons any which doesn't exist (could not find package cupertino_icons at https://storage.flutter-io.cn), version solving failed.
pub get failed (server unavailable) -- attempting retry 4 in 8 seconds...
Running "flutter pub get" in flutter_cmd...                            |终止批处理操作吗(Y/N)? y

D:\002_Project\002_Android_Learn\Flutter_Cmd>

【错误记录】命令行创建 Flutter 应用报错 pub get failed (server unavailable) -- attempting retry 1 in 1 second..._第1张图片





二、 解决方案



Flutter 的两个源没有设置对 , 之前遇到过这个问题 , 也是由于源失效导致 ;

【错误记录】Flutter 报错 Downloading the Dart SDK using the BITS service failed, retrying with WebRequest…

使用官方中文社区的源 , 即可完成命令行创建 ;

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

【错误记录】命令行创建 Flutter 应用报错 pub get failed (server unavailable) -- attempting retry 1 in 1 second..._第2张图片

【错误记录】命令行创建 Flutter 应用报错 pub get failed (server unavailable) -- attempting retry 1 in 1 second..._第3张图片

你可能感兴趣的:(错误记录,Flutter,Flutter)