Flutter 项目向我展示了一个带有建议解决方案的警告'Packages get' has not been run
,
- 获取依赖项
- 升级依赖项
- 忽视
正如Darky所建议的那样,在此答案中继续"获取依赖项">
我试过了,但它向我显示了一个错误:
酒吧失败
/SoftSources/Flutter/flutter/bin/flutter --no-color packages get
Running "flutter packages get" in catalog...
Incompatible version constraints on test:
- flutter_test 0.0.0 depends on version 0.12.30+3
- sample_catalog depends on version 0.12.30+4
pub get failed (1)
Process finished with exit code 1
错误表明项目版本(或其他内容(存在问题,应该在我的颤振项目中在哪里更改它?
编辑:pubspec.yaml
name: sample_catalog
description: A collection of Flutter sample apps
dependencies:
flutter:
sdk: flutter
path: 1.5.1
dev_dependencies:
flutter_test:
sdk: flutter
flutter_driver:
sdk: flutter
args: 1.3.0 # TRANSITIVE DEPENDENCY
async: 2.0.4 # TRANSITIVE DEPENDENCY
barback: 0.15.2+14 # TRANSITIVE DEPENDENCY
boolean_selector: 1.0.2 # TRANSITIVE DEPENDENCY
charcode: 1.1.1 # TRANSITIVE DEPENDENCY
cli_util: 0.1.2+1 # TRANSITIVE DEPENDENCY
collection: 1.14.5 # TRANSITIVE DEPENDENCY
convert: 2.0.1 # TRANSITIVE DEPENDENCY
crypto: 2.0.2+1 # TRANSITIVE DEPENDENCY
csslib: 0.14.1 # TRANSITIVE DEPENDENCY
file: 2.3.6 # TRANSITIVE DEPENDENCY
glob: 1.1.5 # TRANSITIVE DEPENDENCY
html: 0.13.2+2 # TRANSITIVE DEPENDENCY
http: 0.11.3+16 # TRANSITIVE DEPENDENCY
http_multi_server: 2.0.4 # TRANSITIVE DEPENDENCY
http_parser: 3.1.1 # TRANSITIVE DEPENDENCY
intl: 0.15.2 # TRANSITIVE DEPENDENCY
io: 0.3.2+1 # TRANSITIVE DEPENDENCY
isolate: 1.1.0 # TRANSITIVE DEPENDENCY
js: 0.6.1 # TRANSITIVE DEPENDENCY
json_rpc_2: 2.0.7 # TRANSITIVE DEPENDENCY
logging: 0.11.3+1 # TRANSITIVE DEPENDENCY
matcher: 0.12.1+4 # TRANSITIVE DEPENDENCY
meta: 1.1.2 # TRANSITIVE DEPENDENCY
mime: 0.9.6 # TRANSITIVE DEPENDENCY
mockito: 2.2.3 # TRANSITIVE DEPENDENCY
multi_server_socket: 1.0.1 # TRANSITIVE DEPENDENCY
node_preamble: 1.4.0 # TRANSITIVE DEPENDENCY
package_config: 1.0.3 # TRANSITIVE DEPENDENCY
package_resolver: 1.0.2 # TRANSITIVE DEPENDENCY
plugin: 0.2.0+2 # TRANSITIVE DEPENDENCY
pool: 1.3.4 # TRANSITIVE DEPENDENCY
pub_semver: 1.3.2 # TRANSITIVE DEPENDENCY
quiver: 0.28.0 # TRANSITIVE DEPENDENCY
shelf: 0.7.2 # TRANSITIVE DEPENDENCY
shelf_packages_handler: 1.0.3 # TRANSITIVE DEPENDENCY
shelf_static: 0.2.7 # TRANSITIVE DEPENDENCY
shelf_web_socket: 0.2.2 # TRANSITIVE DEPENDENCY
source_map_stack_trace: 1.1.4 # TRANSITIVE DEPENDENCY
source_maps: 0.10.4 # TRANSITIVE DEPENDENCY
source_span: 1.4.0 # TRANSITIVE DEPENDENCY
stack_trace: 1.9.1 # TRANSITIVE DEPENDENCY
stream_channel: 1.6.3 # TRANSITIVE DEPENDENCY
string_scanner: 1.0.2 # TRANSITIVE DEPENDENCY
term_glyph: 1.0.0 # TRANSITIVE DEPENDENCY
test: 0.12.30+4 # TRANSITIVE DEPENDENCY
typed_data: 1.1.5 # TRANSITIVE DEPENDENCY
utf: 0.9.0+4 # TRANSITIVE DEPENDENCY
vector_math: 2.0.5 # TRANSITIVE DEPENDENCY
vm_service_client: 0.2.4+1 # TRANSITIVE DEPENDENCY
watcher: 0.9.7+7 # TRANSITIVE DEPENDENCY
web_socket_channel: 1.0.7 # TRANSITIVE DEPENDENCY
yaml: 2.1.13 # TRANSITIVE DEPENDENCY
flutter:
uses-material-design: true
对于 Flutter 项目运行
flutter packages get
而不是
pub get packages
在开发依赖项中替换
test: 0.12.30+4 # TRANSITIVE DEPENDENCY
跟 test: 0.12.30+3
或者,您可以在颤振时切换到主分支。因为你很可能克隆了一个基于 Flutter 主控的项目示例
来自Windows操作系统的人,仍然无法解决pub get failed (1; no message) exit code 1
问题,您可以尝试以下步骤:
- 开放
Start -> Run -> regedit
- 转到
HKEY_LOCAL_MACHINESoftwareMicrosoftCommand ProcessorAutorun
(如果不存在,请创建一个字符串值( - 将值更改为
@chcp 65001>nul
- 运行
flutter upgrade --force
- 在颤振项目文件夹中运行
flutter pub get
如果它不再显示pub get failed
,则可以在应用模拟器或物理设备中运行应用。
注意:这可能需要一些时间才能运行您的应用。
最后但并非最不重要的一点是,pub get failed
对我来说是一个可怕的错误!
从这里收集的解决方案
单击链接在给定环境中获取包,例如 VS 代码或在打开 pubspec.yaml 文件时保存您的代码将自动为您获取 Flutter 包。
检查 pubspec.yaml 中的语法,它应该看起来像这样
dependencies:
flutter:
sdk: flutter
provider: ^6.0.0
cupertino_icons: ^1.0.2
我所拥有的是这样的,这是不正确的。
dependencies:
flutter:
sdk: flutter
provider: ^6.0.0
cupertino_icons: ^1.0.2
另一件事是检查其他文件中的语法错误,例如缺少 ] 或 (。我遇到了这两个问题,一旦修复,错误就消失了。
在我遇到类似错误的情况下,我在依赖项中指定了intl: 0.18.0
。删除它后,一切正常。
1.更新颤振不起作用
2.重新启动电脑将不起作用
3.创建新项目并运行 pub get 将不起作用。
那么唯一的解决方案是暂时使用VPN。有一些网络问题导致了这个问题。