zl程序教程

您现在的位置是:首页 >  移动开发

当前栏目

【Android Gradle 插件】Android 依赖管理 ⑤ ( Gradle 依赖优化 | 命令行查看依赖模块 | 依赖冲突问题 | 依赖传递冲突 | 分库冲突 | 依赖分组不同导致冲突 )

2023-06-13 09:18:06 时间

文章目录

一、Gradle 依赖优化


Gradle 依赖优化 :

① 依赖库版本选择 : 在 build.gradle 构建脚本中 , 如果设置了多个版本的依赖库 , Gradle 构建时会默认选择最高版本的依赖库 ;

下面的代码中 , " androidx.appcompat:appcompat " 依赖库 配置了 1.1.0 / 1.2.0 / 1.5.1 三个版本 , 在构建时会自动选择最高版本的依赖库 , 即 ‘androidx.appcompat:appcompat:1.5.1’ 依赖库 ;

dependencies {

    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.appcompat:appcompat:1.5.1'
}

② 自动去重 : 如果引入了重复的依赖库 , 系统会自动去重 ;

示例 : 在构建脚本中引入了 A 依赖库 , A 依赖库又依赖于 B 依赖库 , 同时应用中又依赖 B 依赖库 , 这样就导致应用中引入了两次 B 依赖库 , 在构建时 , 系统会自动去掉一个重复的 B 依赖库 ;

下面这种情况 , 在构建脚本中配置了两个相同的依赖库 , 也会自动去重 ;

dependencies {

    implementation 'androidx.appcompat:appcompat:1.5.1'
    implementation 'androidx.appcompat:appcompat:1.5.1'
}

③ 依赖传递 : 在 Gradle 构建过程中 , 是默认支持依赖传递的 ;

二、命令行查看依赖模块


在 Android Studio 的 Terminal 面板中 , 执行

gradlew app:dependencies --configuration releaseRuntimeClasspath

命令 , 可以查看应用的依赖情况 ;

依赖配置如下 :

dependencies {

    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.appcompat:appcompat:1.5.1'
    implementation 'com.google.android.material:material:1.6.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

输出内容如下 :

Y:\002_WorkSpace\001_AS\MyPlugin>gradlew app:dependencies --configuration releaseRuntimeClasspath
WARNING:: Please remove usages of `jcenter()` Maven repository from your build scripts and migrate your build to other Maven repositories.
This repository is deprecated and it will be shut down in the future.
See http://developer.android.com/r/tools/jcenter-end-of-service for more information.
Currently detected usages in: root project 'MyPlugin', project ':app'

> Task :app:dependencies

------------------------------------------------------------
Project :app
------------------------------------------------------------

releaseRuntimeClasspath - Resolved configuration for runtime for variant: release
+--- androidx.appcompat:appcompat:1.1.0 -> 1.5.1
|    +--- androidx.activity:activity:1.5.1
|    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    +--- androidx.collection:collection:1.0.0 -> 1.1.0
|    |    |    \--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    +--- androidx.core:core:1.8.0
|    |    |    +--- androidx.annotation:annotation:1.2.0 -> 1.3.0
|    |    |    +--- androidx.annotation:annotation-experimental:1.1.0
|    |    |    +--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
|    |    |    +--- androidx.concurrent:concurrent-futures:1.0.0
|    |    |    |    +--- com.google.guava:listenablefuture:1.0
|    |    |    |    \--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    |    +--- androidx.lifecycle:lifecycle-runtime:2.3.1 -> 2.5.1
|    |    |    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    |    |    +--- androidx.arch.core:core-common:2.1.0
|    |    |    |    |    \--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    |    |    +--- androidx.arch.core:core-runtime:2.1.0
|    |    |    |    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    |    |    |    \--- androidx.arch.core:core-common:2.1.0 (*)
|    |    |    |    \--- androidx.lifecycle:lifecycle-common:2.5.1
|    |    |    |         \--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    |    \--- androidx.versionedparcelable:versionedparcelable:1.1.1
|    |    |         +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    |         \--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
|    |    +--- androidx.lifecycle:lifecycle-runtime:2.5.1 (*)
|    |    +--- androidx.lifecycle:lifecycle-viewmodel:2.5.1
|    |    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.6.21 -> 1.7.10
|    |    |    |    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10
|    |    |    |    \--- org.jetbrains:annotations:13.0
|    |    |    \--- androidx.lifecycle:lifecycle-viewmodel-savedstate:2.5.1 (c)
|    |    +--- androidx.lifecycle:lifecycle-viewmodel-savedstate:2.5.1
|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.3.0
|    |    |    +--- androidx.core:core-ktx:1.2.0 -> 1.8.0
|    |    |    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    |    |    +--- androidx.core:core:1.8.0 (*)
|    |    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.6.21 -> 1.7.10 (*)
|    |    |    +--- androidx.lifecycle:lifecycle-livedata-core:2.5.1
|    |    |    |    +--- androidx.arch.core:core-common:2.1.0 (*)
|    |    |    |    +--- androidx.arch.core:core-runtime:2.1.0 (*)
|    |    |    |    \--- androidx.lifecycle:lifecycle-common:2.5.1 (*)
|    |    |    +--- androidx.lifecycle:lifecycle-viewmodel:2.5.1 (*)
|    |    |    +--- androidx.savedstate:savedstate:1.2.0
|    |    |    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    |    |    +--- androidx.arch.core:core-common:2.1.0 (*)
|    |    |    |    +--- androidx.lifecycle:lifecycle-common:2.4.0 -> 2.5.1 (*)
|    |    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.6.20 -> 1.7.10 (*)
|    |    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.6.21 -> 1.7.10 (*)
|    |    |    \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1
|    |    |         +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1
|    |    |         |    \--- org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.1
|    |    |         |         +--- org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.1
|    |    |         |         |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1 (c)
|    |    |         |         |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1 (c)
|    |    |         |         |    \--- org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.1 (c)
|    |    |         |         +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0
|    |    |         |         |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.6.0 -> 1.7.10 (*)
|    |    |         |         |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.0
|    |    |         |         |         \--- org.jetbrains.kotlin:kotlin-stdlib:1.6.0 -> 1.7.10 (*)
|    |    |         |         \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.6.0 -> 1.7.10
|    |    |         +--- org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.1 (*)
|    |    |         \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0 (*)
|    |    +--- androidx.savedstate:savedstate:1.2.0 (*)
|    |    +--- androidx.tracing:tracing:1.0.0
|    |    |    \--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.6.21 -> 1.7.10 (*)
|    +--- androidx.annotation:annotation:1.3.0
|    +--- androidx.appcompat:appcompat-resources:1.5.1
|    |    +--- androidx.annotation:annotation:1.2.0 -> 1.3.0
|    |    +--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
|    |    +--- androidx.core:core:1.6.0 -> 1.8.0 (*)
|    |    +--- androidx.vectordrawable:vectordrawable:1.1.0
|    |    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    |    +--- androidx.core:core:1.1.0 -> 1.8.0 (*)
|    |    |    \--- androidx.collection:collection:1.1.0 (*)
|    |    +--- androidx.vectordrawable:vectordrawable-animated:1.1.0
|    |    |    +--- androidx.vectordrawable:vectordrawable:1.1.0 (*)
|    |    |    +--- androidx.interpolator:interpolator:1.0.0
|    |    |    |    \--- androidx.annotation:annotation:1.0.0 -> 1.3.0
|    |    |    \--- androidx.collection:collection:1.1.0 (*)
|    |    \--- androidx.appcompat:appcompat:1.5.1 (c)
|    +--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
|    +--- androidx.core:core:1.8.0 (*)
|    +--- androidx.core:core-ktx:1.8.0 (*)
|    +--- androidx.cursoradapter:cursoradapter:1.0.0
|    |    \--- androidx.annotation:annotation:1.0.0 -> 1.3.0
|    +--- androidx.drawerlayout:drawerlayout:1.0.0 -> 1.1.1
|    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    +--- androidx.core:core:1.2.0 -> 1.8.0 (*)
|    |    \--- androidx.customview:customview:1.1.0
|    |         +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |         +--- androidx.core:core:1.3.0 -> 1.8.0 (*)
|    |         \--- androidx.collection:collection:1.1.0 (*)
|    +--- androidx.emoji2:emoji2:1.2.0
|    |    +--- androidx.annotation:annotation:1.2.0 -> 1.3.0
|    |    +--- androidx.collection:collection:1.1.0 (*)
|    |    +--- androidx.core:core:1.3.0 -> 1.8.0 (*)
|    |    +--- androidx.lifecycle:lifecycle-process:2.4.1
|    |    |    +--- androidx.lifecycle:lifecycle-runtime:2.4.1 -> 2.5.1 (*)
|    |    |    +--- androidx.startup:startup-runtime:1.1.1
|    |    |    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    |    |    \--- androidx.tracing:tracing:1.0.0 (*)
|    |    |    \--- androidx.annotation:annotation:1.2.0 -> 1.3.0
|    |    \--- androidx.startup:startup-runtime:1.0.0 -> 1.1.1 (*)
|    +--- androidx.emoji2:emoji2-views-helper:1.2.0
|    |    +--- androidx.collection:collection:1.1.0 (*)
|    |    +--- androidx.core:core:1.3.0 -> 1.8.0 (*)
|    |    \--- androidx.emoji2:emoji2:1.2.0 (*)
|    +--- androidx.fragment:fragment:1.3.6
|    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    +--- androidx.core:core:1.2.0 -> 1.8.0 (*)
|    |    +--- androidx.collection:collection:1.1.0 (*)
|    |    +--- androidx.viewpager:viewpager:1.0.0
|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.3.0
|    |    |    +--- androidx.core:core:1.0.0 -> 1.8.0 (*)
|    |    |    \--- androidx.customview:customview:1.0.0 -> 1.1.0 (*)
|    |    +--- androidx.loader:loader:1.0.0
|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.3.0
|    |    |    +--- androidx.core:core:1.0.0 -> 1.8.0 (*)
|    |    |    +--- androidx.lifecycle:lifecycle-livedata:2.0.0
|    |    |    |    +--- androidx.arch.core:core-runtime:2.0.0 -> 2.1.0 (*)
|    |    |    |    +--- androidx.lifecycle:lifecycle-livedata-core:2.0.0 -> 2.5.1 (*)
|    |    |    |    \--- androidx.arch.core:core-common:2.0.0 -> 2.1.0 (*)
|    |    |    \--- androidx.lifecycle:lifecycle-viewmodel:2.0.0 -> 2.5.1 (*)
|    |    +--- androidx.activity:activity:1.2.4 -> 1.5.1 (*)
|    |    +--- androidx.lifecycle:lifecycle-livedata-core:2.3.1 -> 2.5.1 (*)
|    |    +--- androidx.lifecycle:lifecycle-viewmodel:2.3.1 -> 2.5.1 (*)
|    |    +--- androidx.lifecycle:lifecycle-viewmodel-savedstate:2.3.1 -> 2.5.1 (*)
|    |    +--- androidx.savedstate:savedstate:1.1.0 -> 1.2.0 (*)
|    |    \--- androidx.annotation:annotation-experimental:1.0.0 -> 1.1.0
|    +--- androidx.lifecycle:lifecycle-runtime:2.5.1 (*)
|    +--- androidx.lifecycle:lifecycle-viewmodel:2.5.1 (*)
|    +--- androidx.resourceinspection:resourceinspection-annotation:1.0.1
|    |    \--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    +--- androidx.savedstate:savedstate:1.2.0 (*)
|    +--- org.jetbrains.kotlin:kotlin-stdlib:1.7.10 (*)
|    \--- androidx.appcompat:appcompat-resources:1.5.1 (c)
+--- androidx.appcompat:appcompat:1.2.0 -> 1.5.1 (*)
+--- androidx.appcompat:appcompat:1.5.1 (*)
+--- com.google.android.material:material:1.6.1
|    +--- androidx.annotation:annotation:1.2.0 -> 1.3.0
|    +--- androidx.appcompat:appcompat:1.1.0 -> 1.5.1 (*)
|    +--- androidx.cardview:cardview:1.0.0
|    |    \--- androidx.annotation:annotation:1.0.0 -> 1.3.0
|    +--- androidx.coordinatorlayout:coordinatorlayout:1.1.0
|    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    +--- androidx.core:core:1.1.0 -> 1.8.0 (*)
|    |    +--- androidx.customview:customview:1.0.0 -> 1.1.0 (*)
|    |    \--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
|    +--- androidx.constraintlayout:constraintlayout:2.0.1 -> 2.1.4
|    |    +--- androidx.appcompat:appcompat:1.2.0 -> 1.5.1 (*)
|    |    +--- androidx.core:core:1.3.2 -> 1.8.0 (*)
|    |    \--- androidx.constraintlayout:constraintlayout-core:1.0.4
|    +--- androidx.core:core:1.5.0 -> 1.8.0 (*)
|    +--- androidx.drawerlayout:drawerlayout:1.1.1 (*)
|    +--- androidx.dynamicanimation:dynamicanimation:1.0.0
|    |    +--- androidx.core:core:1.0.0 -> 1.8.0 (*)
|    |    +--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
|    |    \--- androidx.legacy:legacy-support-core-utils:1.0.0
|    |         +--- androidx.annotation:annotation:1.0.0 -> 1.3.0
|    |         +--- androidx.core:core:1.0.0 -> 1.8.0 (*)
|    |         +--- androidx.documentfile:documentfile:1.0.0
|    |         |    \--- androidx.annotation:annotation:1.0.0 -> 1.3.0
|    |         +--- androidx.loader:loader:1.0.0 (*)
|    |         +--- androidx.localbroadcastmanager:localbroadcastmanager:1.0.0
|    |         |    \--- androidx.annotation:annotation:1.0.0 -> 1.3.0
|    |         \--- androidx.print:print:1.0.0
|    |              \--- androidx.annotation:annotation:1.0.0 -> 1.3.0
|    +--- androidx.annotation:annotation-experimental:1.0.0 -> 1.1.0
|    +--- androidx.fragment:fragment:1.2.5 -> 1.3.6 (*)
|    +--- androidx.lifecycle:lifecycle-runtime:2.0.0 -> 2.5.1 (*)
|    +--- androidx.recyclerview:recyclerview:1.0.0 -> 1.1.0
|    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    +--- androidx.core:core:1.1.0 -> 1.8.0 (*)
|    |    +--- androidx.customview:customview:1.0.0 -> 1.1.0 (*)
|    |    \--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
|    +--- androidx.transition:transition:1.2.0
|    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    +--- androidx.core:core:1.0.1 -> 1.8.0 (*)
|    |    \--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
|    +--- androidx.vectordrawable:vectordrawable:1.1.0 (*)
|    \--- androidx.viewpager2:viewpager2:1.0.0
|         +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|         +--- androidx.fragment:fragment:1.1.0 -> 1.3.6 (*)
|         +--- androidx.recyclerview:recyclerview:1.1.0 (*)
|         +--- androidx.core:core:1.1.0 -> 1.8.0 (*)
|         \--- androidx.collection:collection:1.1.0 (*)
\--- androidx.constraintlayout:constraintlayout:2.1.4 (*)

(c) - dependency constraint
(*) - dependencies omitted (listed previously)

A web-based, searchable dependency report is available by adding the --scan option.

BUILD SUCCESSFUL in 2s
1 actionable task: 1 executed

1、使用最高版本依赖选择

在 构建脚本 中 , 配置了三个版本的 androidx.appcompat:appcompat 依赖 , 会自动选择最高版本的依赖 ;

dependencies {

    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.appcompat:appcompat:1.5.1'
}

在查看依赖时 , 命令行中的 androidx.appcompat:appcompat:1.1.0 -> 1.5.1 内容 , 说明分析到了 androidx.appcompat:appcompat:1.1.0 依赖 , 但同时该构建脚本中又配置了更高版本的依赖 androidx.appcompat:appcompat:1.5.1 ;

如果出现 -> 符号 , 那么该符号右侧的版本就是 Gradle 构建工具选择生效的依赖版本 ,

  • androidx.appcompat:appcompat:1.1.0 版本的依赖作废 ,
  • 使用 androidx.appcompat:appcompat:1.5.1 版本的依赖作为正式版本 ;

2、排除重复依赖

在依赖查看时 , 如果一个依赖后有 (*) 内容 , 说明该依赖已经存在 , 不需要再次导入 , 该依赖已经被 Gradle 构建工具自动去重了 ;

如下代码中 , 最后一行的 androidx.collection:collection:1.0.0 -> 1.1.0 (*) 代码 , 就是被自动去重了 , 该依赖在 androidx.activity:activity:1.5.1 依赖库中被引用 , 同时在 androidx.core:core:1.8.0 依赖库中被引用 , 该依赖只需要导入一次即可 ;

  • androidx.activity:activity:1.5.1 依赖库中存在 androidx.collection:collection:1.0.0 -> 1.1.0 依赖 , 这是第一次被导入 ;
  • androidx.core:core:1.8.0 依赖库中存在 androidx.collection:collection:1.0.0 -> 1.1.0 依赖 , 这是第二次被导入 , 由于之前已经导入了该依赖 , 本次导入被自动去重 ;
+--- androidx.appcompat:appcompat:1.1.0 -> 1.5.1
|    +--- androidx.activity:activity:1.5.1
|    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    +--- androidx.collection:collection:1.0.0 -> 1.1.0
|    |    |    \--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    +--- androidx.core:core:1.8.0
|    |    |    +--- androidx.annotation:annotation:1.2.0 -> 1.3.0
|    |    |    +--- androidx.annotation:annotation-experimental:1.1.0
|    |    |    +--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)

3、排除重复依赖 + 最高版本依赖选择

androidx.appcompat:appcompat:1.2.0 -> 1.5.1 (*) 代码 是 排除重复依赖 + 最高版本依赖选择 ;

在之前分析 androidx.appcompat:appcompat:1.1.0 依赖时 , 就已经自动选择了 最高版本依赖 androidx.appcompat:appcompat:1.5.1 ;

然后在分析 androidx.appcompat:appcompat:1.2.0 依赖时 , 还是自动选择最高版本 androidx.appcompat:appcompat:1.5.1 进行替代 , 但是该最高版本已经被导入了 , 不需要重复导入 , 这里自动去重 , 因此又使用了 (*) 符号 ;

+--- androidx.appcompat:appcompat:1.1.0 -> 1.5.1
|    +--- androidx.activity:activity:1.5.1
|    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    +--- androidx.collection:collection:1.0.0 -> 1.1.0
|    |    |    \--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    +--- androidx.core:core:1.8.0

// 省略 ... 行

+--- androidx.appcompat:appcompat:1.2.0 -> 1.5.1 (*)
+--- androidx.appcompat:appcompat:1.5.1 (*)
+--- com.google.android.material:material:1.6.1

三、依赖传递冲突解决方案


1、依赖传递冲突

依赖传递冲突 : 在依赖配置中 , 可能存在这种情况 ,

  • 应用中引入了第三方库 A , A 存在 B 依赖库的 1.0 版本依赖 ,
  • 同时应用中又导入了 B 依赖库的 2.0 版本依赖 ,

按照 Gradle 依赖优化的原则 , B 依赖库 同时导入了 1.0 和 2.0 两个版本 , 会自动选择最高版本 2.0 , 但是 A 依赖库不兼容 2.0 版本的 B 依赖库 , 这就导致了依赖冲突 ;

这是由于程序传递 , 导致的程序间依赖库不兼容 的 依赖冲突问题 ;

这是由于依赖版本不同导致的依赖冲突 ;

2、分库冲突

依赖库可能存在分库 , 如 :

依赖库 A 中 , 包含了 B , C 分库 , 它们的所有版本都是 1.0 版本 ; 这两个分库是无法分开的 ;

应用突然 单独的依赖了 2.0 版本的 B 依赖库 , 这就出现了冲突 , 此时就会引入了两个版本的 B 依赖库 , 导致了冲突 ;

这是由于依赖版本不同导致的依赖冲突 ;

3、赖分组不同导致冲突

在之前开发中使用的是 support 依赖库 , 但是新版本的 Android 开发时使用 androidx 依赖库 , 这就导致了冲突 ;

这是由于依赖分组不同导致的依赖冲突 ;

4、解决思路

依赖冲突的本质是 一个类 出现了 两次 , 而且所处的依赖库的版本不同 , 或者 依赖分组不同 ;

通过排除依赖或者强制指定依赖 , 可解决依赖冲突 ;