前几天好好的flutter项目在自己的电脑上突然不能下载部分依赖了,明明都是同样的环境配置,同事的电脑没问题,自己家的电脑运行也没问题,问题就出在image_picker这个插件上,一直提示
Got TLS error trying to find package flutter_plugin_android_lifecycle at https://pub.flutter-io.cn
除了这个插件,flutter_quill也是同样的问题,
Got TLS error trying to find package html2md at https://pub.flutter-io.cn
只是提示不同。现在就是只能屏蔽这两个插件,相关的页面暂时不去碰。
网上查询了很多,内外网都查了,查到的几个方法也不行,尝试了以下方法,
修改镜像源,改了清华和交大的源,也不行,很奇怪的一点是,在项目文件夹内通过
powershell
运行pub get
,连接到的是修改后的源,但是在vscode或者AS中,连接的还是修改前的https://pub.flutter-io.cn,清除了缓存也没变。另外,使用清华源提示Flutter assets will be downloaded from https://mirrors.tuna.tsinghua.edu.cn/flutter. Make sure you trust this source! FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':device_info_plus:compileDebugJavaWithJavac'.����: ��Ч��Դ���а棺17
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 37s
Running Gradle task 'assembleDebug'... 37.7s
Error: Gradle task assembleDebug failed with exit code 1
使用交大源提示
Flutter assets will be downloaded from https://mirror.sjtu.edu.cn. Make sure you trust this source!
Resolving dependencies... (3.0s)
Downloaded archive for shared_preferences_android-2.2.1 had wrong content-hash.
This indicates a problem on the package repository: `https://mirror.sjtu.edu.cn/dart-pub/`.
See https://dart.dev/go/content-hashes.
package:pub/src/source/hosted.dart 1368:7 HostedSource._throwFriendlyError
package:pub/src/source/hosted.dart 1195:9 HostedSource._download.<fn>
===== asynchronous gap ===========================
package:pub/src/io.dart 985:12 withTempDir
===== asynchronous gap ===========================
package:pub/src/source/hosted.dart 1122:12 HostedSource._download
===== asynchronous gap ===========================
package:pub/src/source/hosted.dart 871:21 HostedSource.downloadToSystemCache
===== asynchronous gap ===========================
package:pub/src/system_cache.dart 239:20 SystemCache.downloadPackage
===== asynchronous gap ===========================
package:pub/src/solver/result.dart 71:21 SolveResult.downloadCachedPackages.<fn>.<fn>
===== asynchronous gap ===========================
package:pub/src/solver/result.dart 69:18 SolveResult.downloadCachedPackages.<fn>
===== asynchronous gap ===========================
package:pub/src/solver/result.dart 66:32 SolveResult.downloadCachedPackages
===== asynchronous gap ===========================
package:pub/src/entrypoint.dart 380:25 Entrypoint.acquireDependencies
===== asynchronous gap ===========================
package:pub/src/command/get.dart 77:5 GetCommand.runProtected
This is an unexpected error. The full log and other details are collected in:
- 防火墙什么的也给关了测试了。
- 系统也添加了pub的pem证书,
DART_VM_OPTIONS
也配置了。 - 电脑连接手机热点进行下载。
我现在甚至想重装系统了,但是重装的代价太大,是否有人碰到过类似问题,如何解决的呢。
以下是系统信息:
系统:windows10 22H2
flutter版本: 3.19.5
dart版本:3.3.3
以下是yaml部分配置信息:
# 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: '>=3.2.5 <4.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
dio: ^5.4.1
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
bottom_bar_matu: ^1.3.1
salomon_bottom_bar: ^3.3.2
modal_bottom_sheet: ^3.0.0-pre
get: ^4.6.6
shared_preferences: ^2.2.2
bottom_navy_bar: ^6.0.0
convex_bottom_bar: ^3.2.0
flutter_staggered_grid_view: ^0.7.0
easy_refresh: ^3.3.4
flutter_spinkit: ^5.2.0
badges: ^3.1.2
flutter_im_list: ^1.0.0
cached_network_image: ^3.3.1
card_swiper: ^3.0.1
photo_view: ^0.14.0
like_button: ^2.0.5
# image_picker: ^1.0.7
bruno: ^3.4.3
qr_flutter: ^4.1.0
font_awesome_flutter: ^10.7.0
table_calendar: ^3.0.9
fluwx: ^4.5.5
tencent_kit: ^6.0.1
flutter_cache_manager: ^3.3.1
flutter_quill: ^9.3.0
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
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
# To add assets to your application, add an assets section, like this:
assets:
- assets/image/
- assets/icons/
# 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
2024-04-17补充,今天又出现了一些插件无法下载的提示,
Got TLS error trying to find package shared_preferences at https://pub.flutter-io.cn.
Got TLS error trying to find package path_provider at https://pub.flutter-io.cn.
历时一个月,今天无意间解决了,起初是连接三方的vpn接入对方的局域网上传代码,但是也是死活连不上,以前是没问题的,然后按照给出的错误提示网上找了一下,找到了一个能用的解决办法,就是在设备管理器-网络适配器 中删除所有的WAN Miniport设备,然后重启电脑,系统会自动重新安装驱动,重启之后vpn能连了,然后我突然想到了这个flutter项目的问题,重新试了一下,果然,所有依赖都能下载了,困扰了一个多月的问题迎刃而解,这下终于可以不用另一台电脑或者重装系统了,毕竟安装的东西太多了,太麻烦。至于原因,我现在猜测是因为用了梯子,软件修改了系统的网络设置。