Flutter 使用中的版本冲突问题

目录

问题

1、bmob的版本与 dio ^2.1.0 冲突

2、AndroidX 版本问题


问题

1、bmob的版本与 dio ^2.1.0 冲突

Flutter 开发可以使用Bmob的数据作为测试使用,具体的使用方法参照Bmob的文档,本文只记录部分问题的解决方式!

Bmob flutter 文档地址 http://doc.bmob.cn/data/flutter/

没有什么好的方法 目前 bmob 官方的方法是基于 dio ^ 1.0.12 的 如果不想更改 自己项目里的dio的版本,那么只能下载 Bmob提供的源码,我们对源码的 dio版本修改成我们需要的版本。

下面放上我修改后的版本的bmob的源码

链接:https://pan.baidu.com/s/1v0pWe6VDyh6DSxeEFuTgdA
提取码:6yv2
 

需要在 pubspec.yaml 文件中添加以下依赖

dependencies 下面添加:

dio: ^2.1.0
cupertino_icons: ^0.1.2
flutter_spinkit: ^1.0.0
json_annotation: ^2.0.0
web_socket_channel: ^1.0.12
dev_dependencies 下面添加
build_runner: ^1.0.0
json_serializable: ^2.0.0

注意缩进格式,参考下图

2、AndroidX 版本问题

在开发中部分版本需要使用到 AndroidX 这个时候会引发一系列的版本冲突。例如 appcompat 与 core 的版本问题。示例如下:

Execution failed for task ':app:preDebugBuild'.
> Android dependency 'androidx.appcompat:appcompat' has different version for the compile (1.0.0) and runtime (1.0.2) classpath. You should manually set the same version via DependencyResolution

或者这样的

java.lang.RuntimeException: Android dependency 'androidx.core:core' has different version for the compile (1.0.0) and runtime (1.0.1) classpath. You should manually set the same version via DependencyResolution

需要解决此问题就得修改对应的依赖库的对应的 appcompat (或者 core ) 的版本号

首先我们用Android studio 打开 项目的 android 项目 file — open — ******/android 以项目形式打开。

项目打开后

然后找到最新的导入的依赖,并打开 对应的依赖下的android目录下的build.gradle

在build.gradle 中找到对应的依赖

根据错误提示 Android dependency 'androidx.appcompat:appcompat' has different version for the compile (1.0.0) and runtime (1.0.2) classpath. You should manually set the same version via DependencyResolution 将版本号改为 1.0.0 就好了。

修改之后重新运行,运行结果

完美解决。

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值