1. 问题
- 在复杂的稍等大点的flutter项目当中,依赖各种第三方框架是很正常,而且也有有很多依赖的,但有时难免存在不同的框架刚好使用了同一个依赖库的不同版本,特别是依赖了系统的某个库的不同版本
- 这个时候就难免会出现同一个依赖库不同版本冲突的编译失败问题
2. 现象
Because flutter_ume 1.1.2 depends on vm_service ^9.4.0 and no versions of flutter_ume match >1.1.2 <2.0.0, flutter_ume ^1.1.2 requires vm_service ^9.4.0.
And because every version of flutter_test from sdk depends on vm_service 13.0.0 and every version of base_utils from path depends on flutter_ume ^1.1.2, flutter_test from sdk is incompatible with base_utils from path.
And because every version of common_data from path depends on base from path which depends on base_utils from path, flutter_test from sdk is incompatible with common_data from path.
So, because common_modules depends on both common_data from path and flutter_test from sdk, version solving failed.
- 一大串文字说明,大概的意思就是
flutter_ume
这个库依赖了系统的vm_service
库版本是^9.4.0
,而flutter_test
这个库依赖了系统的vm_service
库版本是13.0.0
的,出现了版本冲突
3. 解决方法
- 可以使用
dependency_overrides
关键字强制依赖某个版本,即可解决。 - 在pubspec.yaml文件添加以下内容,让项目强制依赖vm_service版本为13.0.0就可以解决,如下所示
dependency_overrides:
vm_service: ^13.0.0
标签:依赖,service,overrides,vm,dependency,版本,flutter
From: https://www.cnblogs.com/yongfengnice/p/18195697