卡在flutter pub get:running中,pubspec.yaml更新后下载不下来

本文提供了解决在国内使用VSCode或AndroidStudio编译Flutter工程时遇到的下载速度慢问题的方法,包括使用翻墙和配置镜像源来加速pubspec.yaml文件的依赖下载。

解决问题:

VSCode 编译flutter工程,pubspec.yaml更新后下载不下来

卡在flutter pub get:running中或者是:通过Android Studio创建flutter工程很慢
或者是:zsh: command not found: flutter问题

 

一、翻墙(自己百度)

二、使用镜像

由于在国内访问Flutter有时可能会受到限制,Flutter官方为中国开发者搭建了临时镜像,大家可以将如下环境变量加入到用户环境变量中:

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

此镜像为临时镜像,并不能保证一直可用,可参考小知识设置永久变量

 

 下面的PWD为你flutterSDK的解压目录

export PATH="$PWD/flutter/bin:$PATH"

 

flutter一点小知识 (更新mac环境变量)

1、查找文件,并打印文件

cat ~/.bash_profile

cat  ~/.zshrc

显示或者隐藏系统文件:com键 + shift + .

找到你的HOME目录,显示隐藏文件,编译.bash_profile,加

export PATH="$PATH:[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin"

然后重新打开一个命令面板。运行以下命令echo $PATH   验证 flutter/bin 是否添加正确

echo $PATH

 

参考文章:https://book.flutterchina.club/chapter1/install_flutter.html

https://flutter.cn/docs/get-started/install/macos

 

分析一下yaml文件格式问题:name: tpub_web description: tpub web # The following line prevents the package from being accidentally published to # pub.dev using `flutter pub publish`. This is preferred for private packages. publish_to: 'none' # Remove this line if you wish to publish to pub.dev # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 # followed by an optional build number separated by a +. # Both the version and the builder number may be overridden in flutter # build by specifying --build-name and --build-number, respectively. # In Android, build-name is used as versionName while build-number used as versionCode. # Read more about Android versioning at https://developer.android.com/studio/publish/versioning # In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. version: 1.0.0+1 environment: sdk: '>=2.19.6 <3.0.0' # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions # consider running `flutter pub upgrade --major-versions`. Alternatively, # dependencies can be manually updated by changing the version numbers below to # the latest version available on pub.dev. To see which dependencies have newer # versions available, run `flutter pub outdated`. dependencies: flutter: sdk: flutter flutter_svg: 1.1.6 trouter: git: url: https://git.woa.com/flutter_components/TRouterGroup/TRouter.git path: trouter ref: master3+ dependency_overrides: trouter_platform_interface: git: url: https://git.woa.com/flutter_components/TRouterGroup/TRouter.git path: trouter_platform_interface ref: master3+ trouter_web: git: url: https://git.woa.com/flutter_components/TRouterGroup/TRouter.git path: trouter_web ref: master3+ # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 dev_dependencies: flutter_test: sdk: flutter # The "flutter_lints" package below contains a set of recommended lints to # encourage good coding practices. The lint set provided by the package is # activated in the `analysis_options.yaml` file located at the root of your # package. See that file for information about deactivating specific lint # rules and activating additional ones. flutter_lints: ^2.0.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec # The following section is specific to Flutter packages. flutter: # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. uses-material-design: true assets: - images/ # To add assets to your application, add an assets section, like this: # assets: # - images/a_dot_burr.jpeg # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware # For details regarding adding assets from package dependencies, see # https://flutter.dev/assets-and-images/#from-packages # To add custom fonts to your application, add a fonts section here, # in this "flutter" section. Each entry in this list should have a # "family" key with the font family name, and a "fonts" key with a # list giving the asset and other descriptors for the font. For # example: # fonts: # - family: Schyler # fonts: # - asset: fonts/Schyler-Regular.ttf # - asset: fonts/Schyler-Italic.ttf # style: italic # - family: Trajan Pro # fonts: # - asset: fonts/TrajanPro.ttf # - asset: fonts/TrajanPro_Bold.ttf # weight: 700 # # For details regarding fonts from package dependencies, # see https://flutter.dev/custom-fonts/#from-packages
06-27
PS D:\vietnam_asd_app\vietnam_asd_app> flutter run Flutter assets will be downloaded from https://storage.googleapis.com/flutter_infra_release. Make sure you trust this source! Launching lib\main.dart on sdk gphone64 x86 64 in debug mode... You are applying Flutter's app_plugin_loader Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/go/flutter-gradle-plugin-apply Flutter assets will be downloaded from https://storage.googleapis.com/flutter_infra_release. Make sure you trust this source! FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:checkDebugAarMetadata'. > Could not resolve all files for configuration ':app:debugRuntimeClasspath'. > Could not find io.flutter:x86_64_debug:1.0.0-edd8546116457bdf1c5bdfb13ecb9463d2bb5ed4. Searched in the following locations: - https://dl.google.com/dl/android/maven2/io/flutter/x86_64_debug/1.0.0-edd8546116457bdf1c5bdfb13ecb9463d2bb5ed4/x86_64_debug-1.0.0-edd8546116457bdf1c5bdfb13ecb9463d2bb5ed4.pom - https://repo.maven.apache.org/maven2/io/flutter/x86_64_debug/1.0.0-edd8546116457bdf1c5bdfb13ecb9463d2bb5ed4/x86_64_debug-1.0.0-edd8546116457bdf1c5bdfb13ecb9463d2bb5ed4.pom - https://storage.googleapis.com/flutter_infra_release/download.flutter.io/io/flutter/x86_64_debug/1.0.0-edd8546116457bdf1c5bdfb13ecb9463d2bb5ed4/x86_64_debug-1.0.0-edd8546116457bdf1c5bdfb13ecb9463d2bb5ed4.pom Required by: project :app > Could not find io.flutter:x86_debug:1.0.0-edd8546116457bdf1c5bdfb13ecb9463d2bb5ed4. Searched in the following locations: - https://dl.google.com/dl/android/maven2/io/flutter/x86_debug/1.0.0-edd8546116457bdf1c5bdfb13ecb9463d2bb5ed4/x86_debug-1.0.0-edd8546116457bdf1c5bdfb13ecb9463d2bb5ed4.pom - https://repo.maven.apache.org/maven2/io/flutter/x86_debug/1.0.0-edd8546116457bdf1c5bdfb13ecb9463d2bb5ed4/x86_debug-1.0.0-edd8546116457bdf1c5bdfb13ecb9463d2bb5ed4.pom - https://storage.googleapis.com/flutter_infra_release/download.flutter.io/io/flutter/x86_debug/1.0.0-edd8546116457bdf1c5bdfb13ecb9463d2bb5ed4/x86_debug-1.0.0-edd8546116457bdf1c5bdfb13ecb9463d2bb5ed4.pom Required by: project :app > Could not find io.flutter:flutter_embedding_debug:1.0.0-edd8546116457bdf1c5bdfb13ecb9463d2bb5ed4. Searched in the following locations: - https://dl.google.com/dl/android/maven2/io/flutter/flutter_embedding_debug/1.0.0-edd8546116457bdf1c5bdfb13ecb9463d2bb5ed4/flutter_embedding_debug-1.0.0-edd8546116457bdf1c5bdfb13ecb9463d2bb5ed4.pom - https://repo.maven.apache.org/maven2/io/flutter/flutter_embedding_debug/1.0.0-edd8546116457bdf1c5bdfb13ecb9463d2bb5ed4/flutter_embedding_debug-1.0.0-edd8546116457bdf1c5bdfb13ecb9463d2bb5ed4.pom - https://storage.googleapis.com/flutter_infra_release/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-edd8546116457bdf1c5bdfb13ecb9463d2bb5ed4/flutter_embedding_debug-1.0.0-edd8546116457bdf1c5bdfb13ecb9463d2bb5ed4.pom Required by: project :app > project :device_info_plus project :app > project :package_info_plus project :app > project :permission_handler_android project :app > project :shared_preferences_android project :app > project :speech_xf project :app > project :url_launcher_android project :app > project :webview_flutter_android * 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 33s Running Gradle task 'assembleDebug'... 34.8s Error: Gradle task assembleDebug failed with exit code 1
最新发布
12-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值