克隆使用旧 sdk 和包的项目后,如何解决所有 sdk 和依赖项问题?

Posted

技术标签:

【中文标题】克隆使用旧 sdk 和包的项目后,如何解决所有 sdk 和依赖项问题?【英文标题】:How to resolve all the sdk and dependencies issues after cloning a project that was using old sdk and packages? 【发布时间】:2020-12-25 12:18:31 【问题描述】:

我已经克隆了由谷歌开发者在 youtube 上的无聊节目系列中开发的hackernews 项目。 在运行 flutter run 时出现这些错误。


The current Dart SDK version is 2.9.2.                                  
                                                                        
    Because no versions of test match >1.13.0 <1.14.0 and test >=1.16.0-nullsafety requires SDK version >=2.10.0-0 <2.10.0, test >1.13.0 <1.14.0-∞ or >=1.16.0-nullsafety is forbidden.
(1) So, because test >=1.3.0 <1.12.0 depends on boolean_selector ^1.0.0 and test >=1.12.0 <1.13.0 depends on test_api 0.2.14, test >=1.3.0 <1.13.0-∞ or >1.13.0 <1.14.0-∞ or >=1.16.0-nullsafety requires boolean_selector ^1.0.0 or test_api 0.2.14.
                                                                        
    Because test >=1.14.5 <1.15.0 depends on test_api 0.2.16 and test >=1.13.0 <1.14.5 depends on test_api 0.2.15, test >=1.13.0 <1.15.0 requires test_api 0.2.15 or 0.2.16.
    And because test >=1.15.0 <1.15.1 depends on test_core 0.3.8, test >=1.13.0 <1.15.1 requires test_api 0.2.15 or 0.2.16 or test_core 0.3.8.
    And because test >=1.15.1 <1.15.2 depends on test_core 0.3.9 and test >=1.15.2 <1.15.3 depends on test_core 0.3.10, test >=1.13.0 <1.15.3 requires test_core 0.3.8 or 0.3.9 or 0.3.10 or test_api 0.2.15 or 0.2.16.
    And because test >=1.3.0 <1.13.0-∞ or >1.13.0 <1.14.0-∞ or >=1.16.0-nullsafety requires boolean_selector ^1.0.0 or test_api 0.2.14 (1), test >=1.3.0 <1.15.3-∞ or >=1.16.0-nullsafety requires boolean_selector ^1.0.0 or test_api 0.2.14 or 0.2.15 or 0.2.16 or test_core 0.3.8 or 0.3.9 or 0.3.10.
    And because every version of flutter_test from sdk depends on both boolean_selector 2.0.0 and test_api 0.2.17, if flutter_test any from sdk and test >=1.3.0 <1.15.3-∞ or >=1.16.0-nullsafety then test_core 0.3.8 or 0.3.9 or 0.3.10.
(2) So, because test >=1.15.3 <1.16.0-nullsafety depends on test_core 0.3.11 which depends on analyzer ^0.39.5, if flutter_test any from sdk and test >=1.3.0 then analyzer ^0.39.5.
                                                                        
    Because no versions of built_value_generator match >6.5.0 <6.6.0 and built_value_generator >=6.6.0 <6.8.0 depends on analyzer >=0.34.0 <0.37.0, built_value_generator >6.5.0 <6.8.0 requires analyzer >=0.34.0 <0.37.0.
    And because built_value_generator >=6.8.0 <7.0.4 depends on analyzer >=0.34.0 <0.39.0 and built_value_generator 6.5.0 depends on analyzer >=0.33.3 <0.37.0, built_value_generator >=6.5.0 <7.0.4 requires analyzer >=0.33.3 <0.39.0.
    And because if flutter_test any from sdk and test >=1.3.0 then analyzer ^0.39.5 (2), one of flutter_test any from sdk or test >=1.3.0 or built_value_generator >=6.5.0 <7.0.4 must be false.
    And because hn_app depends on built_value_generator ^6.5.0, flutter_test from sdk is incompatible with test >=1.3.0.
    So, because hn_app depends on both test ^1.6.1 and flutter_test any from sdk, version solving failed.
Running "flutter pub get" in hn_app...                                  
pub get failed (1;     So, because hn_app depends on both test ^1.6.1 and
flutter_test any from sdk, version solving failed.)

【问题讨论】:

【参考方案1】:

我的问题很相似

就像其他人提到的那样,删除 pubspec.yahml 中的数字

video_player: ^1.15.0

video_player: 

然后

flutter pub outdated
flutter pub upgrade --major-versions

【讨论】:

【参考方案2】:

由于某种原因,在 dependency_overrides 部分添加分析器解决了这个问题。这是我的 pubspec.yaml 文件的样子:

dev_dependencies:
  build_runner: ^1.4.0
  built_value_generator: ^6.5.0
  moor_generator: ^1.4.0

dependency_overrides:
  analyzer: '0.39.14'

【讨论】:

【参考方案3】:

从 pubspec.yaml 中的依赖项中删除所有版本号,让 Flutter 确定版本

例子:

替换这个

test: ^1.15.0
test_core: 0.3.8

有了这个

test: 
test_core: 

【讨论】:

它确实解决了这个错误,但现在我遇到了一些其他错误,因为所有依赖项版本都已更改 我可以对 -----> sdk: ">=2.14.0

以上是关于克隆使用旧 sdk 和包的项目后,如何解决所有 sdk 和依赖项问题?的主要内容,如果未能解决你的问题,请参考以下文章

安卓如何将旧手机所有资料导入新手机

Android Studio修改项目名称和包名方法

6模块和包的导入

FFmpeg中帧和包的区别

python 模块和包的使用方法

python模块和包的导入