App依赖查看及升级

本文详细介绍了Android项目中依赖项的类型,包括本地库模块、本地二进制文件和远程二进制文件依赖,以及如何在项目结构中管理和升级这些依赖。同时,文章提供了依赖树查看的方法和依赖冲突解决方案,并讨论了依赖升级时可能遇到的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

依赖项类型

apply plugin: 'com.android.application'
android { ... }
dependencies { 
    // Dependency on a local library module      本地库模块依赖项
    implementation project(":mylibrary")
   
    // Dependency on local binaries              本地二进制文件依赖项
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    // Dependency on a remote binary             远程二进制文件依赖项
    implementation 'com.example.android:app-magic:12.3'
}

依赖升级

项目通常会统一版本,采用第一行的方式添加依赖,就不会向第二行这样提示你升级(第二行你代码你只需要放上去Alt+Enter就可以选择更新版本号了)

这两种依赖你都可以在‘Project Structure’中 修改版本,如下波浪线提示很明显:

依赖查看

先推荐一篇好文章Android 查看项目依赖树的四种方式

1.项目根目录 - 查看重复依赖

全局搜索'1.0.1',然后修改版本即可

2.命令行 - 查看依赖关系

android studio 4.+已经不再需要命令行查看了,在该讲解后展示!

 ./gradlew :app:dependencies 

也可以启动Gradle task,层级如下,记得是app的,不要选(root),root的‘help/dependencies’,可以用来排查依赖问题:

运行结果

先说说依赖后面有(),代表什么意思(命令行中也有提示的)

 +--- com.android.support:drawerlayout:28.0.0
|    |    |         |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |         |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |         |    |    \--- com.android.support:customview:28.0.0 (*)
(c) - dependency constraint
(*) - dependencies omitted (listed previously)
(n) - Not resolved (configuration is not meant to be resolved)

(c) -依赖限制
(*) -省略依赖项(先前列出)
(n) -未解析(配置不意味着要解析)

->  -On the left side of -> is the requested version, on the right the version that will be picked. Here similar question can be found.(左侧是请求的版本,右侧是将被选中的版本)
(*) It means that elsewhere in the report, the dependency was already presented with the whole subdependencies, hence here it's root only. (这意味着在报告的其他地方,依赖关系已经呈现出整个子依赖关系,因此它只是根源)

官方虽给了解释,但是简短我没能理解 于是google了一下才得到两行英文解释  连接

项目中的module有多渠道,及构建方式,输出结果会把所有三个参数组合起来,分别列出来,module中的module也会列出来(通常依赖内容受 随渠道,构建方式影响不大,我说了通常)。如果项目中有传递依赖,我们只需要找到App的信息就好,所有的依赖就会列出来了,大致如下(渠道:bd,构建方式:Debug,记得要看运行时依赖(Runtime classpath of compilation 'bdDebug')):

bdDebugRuntimeClasspath - Runtime classpath of compilation 'bdDebug' (target  (androidJvm)).
+--- project :bus-common
|    +--- project :libcommon
|    |    +--- io.realm:realm-android-library:5.8.0
|    |    |    +--- com.google.code.findbugs:jsr305:3.0.2
|    |    |    +--- com.getkeepsafe.relinker:relinker:1.3.0
|    |    |    \--- io.realm:realm-annotations:5.8.0
|    |    +--- io.realm:realm-android-kotlin-extensions:5.8.0
|    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.50 -> 1.3.41
|    |    |         \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.41
|    |    |              +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.41
|    |    |              \--- org.jetbrains:annotations:13.0
|    |    +--- io.realm:realm-annotations:5.8.0
|    |    +--- project :oss-android-sdk
|    |    |    +--- com.squareup.okhttp3:okhttp:3.12.0
|    |    |    |    \--- com.squareup.okio:okio:1.15.0
|    |    |    \--- org.jacoco:org.jacoco.agent:0.7.9
|    |    +--- project :mp3recorder
|    |    +--- com.android.support:support-v4:28.0.0
|    |    |    +--- com.android.support:support-compat:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:collections:28.0.0
|    |    |    |    |    \--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- android.arch.lifecycle:runtime:1.1.1
|    |    |    |    |    +--- android.arch.lifecycle:common:1.1.1
|    |    |    |    |    |    \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    |    |    |    +--- android.arch.core:common:1.1.1
|    |    |    |    |    |    \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    |    |    |    \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    |    |    \--- com.android.support:versionedparcelable:28.0.0
|    |    |    |         +--- com.android.support:support-annotations:28.0.0
|    |    |    |         \--- com.android.support:collections:28.0.0 (*)
|    |    |    +--- com.android.support:support-media-compat:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    \--- com.android.support:versionedparcelable:28.0.0 (*)
|    |    |    +--- com.android.support:support-core-utils:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    +--- com.android.support:documentfile:28.0.0
|    |    |    |    |    \--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:loader:28.0.0
|    |    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    |    +--- android.arch.lifecycle:livedata:1.1.1
|    |    |    |    |    |    +--- android.arch.core:runtime:1.1.1
|    |    |    |    |    |    |    +--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    |    |    |    |    |    \--- android.arch.core:common:1.1.1 (*)
|    |    |    |    |    |    +--- android.arch.lifecycle:livedata-core:1.1.1
|    |    |    |    |    |    |    +--- android.arch.lifecycle:common:1.1.1 (*)
|    |    |    |    |    |    |    +--- android.arch.core:common:1.1.1 (*)
|    |    |    |    |    |    |    \--- android.arch.core:runtime:1.1.1 (*)
|    |    |    |    |    |    \--- android.arch.core:common:1.1.1 (*)
|    |    |    |    |    \--- android.arch.lifecycle:viewmodel:1.1.1
|    |    |    |    |         \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    |    |    +--- com.android.support:localbroadcastmanager:28.0.0
|    |    |    |    |    \--- com.android.support:support-annotations:28.0.0
|    |    |    |    \--- com.android.support:print:28.0.0
|    |    |    |         \--- com.android.support:support-annotations:28.0.0
|    |    |    +--- com.android.support:support-core-ui:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    +--- com.android.support:support-core-utils:28.0.0 (*)
|    |    |    |    +--- com.android.support:customview:28.0.0
|    |    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    |    \--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    +--- com.android.support:viewpager:28.0.0
|    |    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    |    \--- com.android.support:customview:28.0.0 (*)
|    |    |    |    +--- com.android.support:coordinatorlayout:28.0.0
|    |    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    |    \--- com.android.support:customview:28.0.0 (*)
|    |    |    |    +--- com.android.support:drawerlayout:28.0.0
|    |    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    |    \--- com.android.support:customview:28.0.0 (*)
|    |    |    |    +--- com.android.support:slidingpanelayout:28.0.0
|    |    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    |    \--- com.android.support:customview:28.0.0 (*)
|    |    |    |    +--- com.android.support:interpolator:28.0.0
|    |    |    |    |    \--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:swiperefreshlayout:28.0.0
|    |    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    |    \--- com.android.support:interpolator:28.0.0 (*)
|    |    |    |    +--- com.android.support:asynclayoutinflater:28.0.0
|    |    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    |    \--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    \--- com.android.support:cursoradapter:28.0.0
|    |    |    |         \--- com.android.support:support-annotations:28.0.0
|    |    |    \--- com.android.support:support-fragment:28.0.0
|    |    |         +--- com.android.support:support-compat:28.0.0 (*)
|    |    |         +--- com.android.support:support-core-ui:28.0.0 (*)
|    |    |         +--- com.android.support:support-core-utils:28.0.0 (*)
|    |    |         +--- com.android.support:support-annotations:28.0.0
|    |    |         +--- com.android.support:loader:28.0.0 (*)
|    |    |         \--- android.arch.lifecycle:viewmodel:1.1.1 (*)
|    |    +--- com.android.support:appcompat-v7:28.0.0
|    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    +--- com.android.support:collections:28.0.0 (*)
|    |    |    +--- com.android.support:cursoradapter:28.0.0 (*)
|    |    |    +--- com.android.support:support-core-utils:28.0.0 (*)
|    |    |    +--- com.android.support:support-fragment:28.0.0 (*)
|    |    |    +--- com.android.support:support-vector-drawable:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    \--- com.android.support:support-compat:28.0.0 (*)
|    |    |    \--- com.android.support:animated-vector-drawable:28.0.0
|    |    |         +--- com.android.support:support-vector-drawable:28.0.0 (*)
|    |    |         \--- com.android.support:support-core-ui:28.0.0 (*)
|    |    +--- com.android.support:design:28.0.0
|    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    +--- com.android.support:support-core-ui:28.0.0 (*)
|    |    |    +--- com.android.support:support-core-utils:28.0.0 (*)
|    |    |    +--- com.android.support:support-fragment:28.0.0 (*)
|    |    |    +--- com.android.support:transition:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    \--- com.android.support:support-compat:28.0.0 (*)
|    |    |    +--- com.android.support:appcompat-v7:28.0.0 (*)
|    |    |    +--- com.android.support:cardview-v7:28.0.0
|    |    |    |    \--- com.android.support:support-annotations:28.0.0
|    |    |    \--- com.android.support:recyclerview-v7:28.0.0
|    |    |         +--- com.android.support:support-annotations:28.0.0
|    |    |         +--- com.android.support:support-compat:28.0.0 (*)
|    |    |         \--- com.android.support:support-core-ui:28.0.0 (*)
|    |    +--- io.reactivex.rxjava2:rxjava:2.2.9
|    |    |    \--- org.reactivestreams:reactive-streams:1.0.2
|    |    +--- io.reactivex.rxjava2:rxandroid:2.1.1
|    |    |    \--- io.reactivex.rxjava2:rxjava:2.2.6 -> 2.2.9 (*)
|    |    +--- com.tbruyelle.rxpermissions2:rxpermissions:0.9.5
|    |    +--- me.yokeyword:fragmentation:1.3.6
|    |    |    \--- me.yokeyword:fragmentation-core:1.3.6
|    |    +--- com.orhanobut:logger:2.2.0
|    |    |    \--- com.android.support:support-annotations:27.1.0 -> 28.0.0
|    |    +--- com.google.code.gson:gson:2.8.5
|    |    +--- com.squareup.retrofit2:retrofit:2.6.0
|    |    |    \--- com.squareup.okhttp3:okhttp:3.12.0 (*)
|    |    +--- com.squareup.retrofit2:converter-gson:2.6.0
|    |    |    +--- com.squareup.retrofit2:retrofit:2.6.0 (*)
|    |    |    \--- com.google.code.gson:gson:2.8.5
|    |    +--- com.squareup.retrofit2:adapter-rxjava2:2.6.0
|    |    |    +--- com.squareup.retrofit2:retrofit:2.6.0 (*)
|    |    |    \--- io.reactivex.rxjava2:rxjava:2.0.0 -> 2.2.9 (*)
|    |    +--- com.squareup.okhttp3:okhttp:3.12.0 (*)
|    |    +--- com.squareup.okhttp3:logging-interceptor:3.12.0
|    |    |    \--- com.squareup.okhttp3:okhttp:3.12.0 (*)
|    |    +--- com.github.bumptech.glide:glide:3.7.0
|    |    +--- com.github.bumptech.glide:okhttp3-integration:1.4.0
|    |    +--- org.jsoup:jsoup:1.10.1
|    |    +--- com.arialyy.aria:aria-core:3.6.4
|    |    |    +--- com.arialyy.aria:aria-annotations:3.6.4
|    |    |    \--- com.arialyy.aria:aria-ftp-plug:1.0.4
|    |    +--- com.jakewharton:butterknife:9.0.0
|    |    |    \--- com.jakewharton:butterknife-runtime:9.0.0
|    |    |         +--- com.jakewharton:butterknife-annotations:9.0.0
|    |    |         |    \--- com.android.support:support-annotations:28.0.0
|    |    |         \--- com.android.support:support-compat:28.0.0 (*)
|    |    +--- com.belerweb:pinyin4j:2.5.1
|    |    +--- com.android.support:multidex:1.0.2
|    |    +--- com.tencent.bugly:crashreport:2.8.6.0
|    |    +--- org.greenrobot:eventbus:3.1.1
|    |    +--- cn.bingoogolapple:bga-qrcode-zbar:1.3.4
|    |    |    \--- cn.bingoogolapple:bga-qrcode-core:1.3.4
|    |    +--- top.zibin:Luban:1.1.3
|    |    +--- com.danikula:videocache:2.7.0
|    |    |    \--- org.slf4j:slf4j-android:1.7.21
|    |    |         \--- org.slf4j:slf4j-api:1.7.21
|    |    +--- com.android.support.constraint:constraint-layout:1.1.3
|    |    |    \--- com.android.support.constraint:constraint-layout-solver:1.1.3
|    |    +--- com.jcodecraeer:xrecyclerview:1.5.9
|    |    |    +--- com.android.support:appcompat-v7:23.4.0 -> 28.0.0 (*)
|    |    |    +--- com.android.support:recyclerview-v7:23.4.0 -> 28.0.0 (*)
|    |    |    \--- com.android.support:design:23.4.0 -> 28.0.0 (*)
|    |    +--- com.android.support:recyclerview-v7:28.0.0 (*)
|    |    +--- es.voghdev.pdfviewpager:library:1.0.5
|    |    |    +--- com.android.support:appcompat-v7:25.4.0 -> 28.0.0 (*)
|    |    |    \--- com.commit451:PhotoView:1.2.4
|    |    |         \--- com.android.support:support-v4:23.0.1 -> 28.0.0 (*)
|    |    +--- project :jpush
|    |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.41 (*)
|    +--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.3.41
|    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.41 (*)
|    +--- com.android.support.constraint:constraint-layout:1.1.3 (*)
|    +--- com.wuxiaolong.pullloadmorerecyclerview:library:1.1.2
|    |    +--- com.android.support:appcompat-v7:25.0.0 -> 28.0.0 (*)
|    |    \--- com.android.support:recyclerview-v7:25.0.0 -> 28.0.0 (*)
|    +--- com.android.support:support-v4:28.0.0 (*)
|    +--- io.reactivex.rxjava2:rxjava:2.2.9 (*)
|    +--- io.reactivex.rxjava2:rxandroid:2.1.1 (*)
|    +--- com.tbruyelle.rxpermissions2:rxpermissions:0.9.5
|    +--- me.yokeyword:fragmentation:1.3.6 (*)
|    +--- com.orhanobut:logger:2.2.0 (*)
|    +--- com.google.code.gson:gson:2.8.5
|    +--- com.squareup.okhttp3:okhttp:3.12.0 (*)
|    +--- com.squareup.retrofit2:retrofit:2.6.0 (*)
|    +--- com.github.bumptech.glide:glide:3.7.0
|    +--- com.belerweb:pinyin4j:2.5.1
|    +--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.41 (*)
|    +--- cn.aigestudio.wheelpicker:WheelPicker:1.1.2
|    +--- com.github.1002326270xc:LayoutManager-FlowLayout:v1.7
|    |    +--- com.android.support:appcompat-v7:25.3.1 -> 28.0.0 (*)
|    |    \--- com.android.support:recyclerview-v7:25.3.1 -> 28.0.0 (*)
|    \--- com.contrarywind:Android-PickerView:4.1.8
|         +--- com.contrarywind:wheelview:4.0.9
|         |    \--- com.android.support:support-annotations:28.0.0
|         \--- com.android.support:support-annotations:28.0.0
+--- com.android.support:multidex:1.0.2
+--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.3.41 (*)
+--- io.socket:socket.io-client:1.0.0
|    \--- io.socket:engine.io-client:1.0.0
|         \--- com.squareup.okhttp3:okhttp:3.8.1 -> 3.12.0 (*)
+--- io.reactivex.rxjava2:rxjava:2.2.9 (*)
+--- io.reactivex.rxjava2:rxandroid:2.1.1 (*)
+--- com.tbruyelle.rxpermissions2:rxpermissions:0.9.5
+--- me.yokeyword:fragmentation:1.3.6 (*)
+--- com.orhanobut:logger:2.2.0 (*)
+--- com.google.code.gson:gson:2.8.5
+--- com.squareup.okhttp3:okhttp:3.12.0 (*)
+--- com.squareup.retrofit2:retrofit:2.6.0 (*)
+--- com.github.bumptech.glide:glide:3.7.0
+--- com.jakewharton:butterknife:9.0.0 (*)
+--- com.belerweb:pinyin4j:2.5.1
+--- org.greenrobot:eventbus:3.1.1
+--- com.android.support.constraint:constraint-layout:1.1.3 (*)
+--- com.zhihu.android:matisse:0.4.3
|    +--- com.android.support:support-v4:25.3.1 -> 28.0.0 (*)
|    +--- com.android.support:appcompat-v7:25.3.1 -> 28.0.0 (*)
|    +--- com.android.support:support-annotations:25.3.1 -> 28.0.0
|    +--- com.android.support:recyclerview-v7:25.3.1 -> 28.0.0 (*)
|    \--- it.sephiroth.android.library.imagezoom:library:1.0.4
|         \--- it.sephiroth.android.library.easing:library:1.0.2
\--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.41 (*)

接下来开始分析问题:

比如这里依赖了知乎的开源库,它自己的版本是0.4.3,而里面依赖的库都不是最新的,说明了一个问题:很有可能‘0.4.3’已经不是最新的版本了。查一下,果然最新的已经是'0.5.2-beta5'。

|    +--- com.android.support:support-v4:25.3.1 -> 28.0.0 (*)

+--- com.zhihu.android:matisse:0.4.3
|    +--- com.android.support:support-v4:25.3.1 -> 28.0.0 (*)
|    +--- com.android.support:appcompat-v7:25.3.1 -> 28.0.0 (*)
|    +--- com.android.support:support-annotations:25.3.1 -> 28.0.0
|    +--- com.android.support:recyclerview-v7:25.3.1 -> 28.0.0 (*)
|    \--- it.sephiroth.android.library.imagezoom:library:1.0.4
|         \--- it.sephiroth.android.library.easing:library:1.0.2

现在的依赖关系如下:

发现这时的依赖变成了androidx,如果你项目使用了androidx 倒是不存在问题,如果没有依赖androidx,你要么去支持androidx(很麻烦的),要么退到没有androidx 的版本,这里是'0.5.2-beta4'。

com.zhihu.android:matisse:0.5.2-beta5
|    +--- androidx.appcompat:appcompat:1.0.2
|    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    +--- androidx.core:core:1.0.1
|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    |    +--- androidx.collection:collection:1.0.0
|    |    |    |    \--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    |    +--- androidx.lifecycle:lifecycle-runtime:2.0.0
|    |    |    |    +--- androidx.lifecycle:lifecycle-common:2.0.0
|    |    |    |    |    \--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    |    |    +--- androidx.arch.core:core-common:2.0.0
|    |    |    |    |    \--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    |    |    \--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    |    \--- androidx.versionedparcelable:versionedparcelable:1.0.0
|    |    |         +--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    |         \--- androidx.collection:collection:1.0.0 (*)
|    |    +--- androidx.collection:collection:1.0.0 (*)
|    |    +--- androidx.cursoradapter:cursoradapter:1.0.0
|    |    |    \--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    +--- androidx.legacy:legacy-support-core-utils:1.0.0
|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    |    +--- androidx.core:core:1.0.0 -> 1.0.1 (*)
|    |    |    +--- androidx.documentfile:documentfile:1.0.0
|    |    |    |    \--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    |    +--- androidx.loader:loader:1.0.0
|    |    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    |    |    +--- androidx.core:core:1.0.0 -> 1.0.1 (*)
|    |    |    |    +--- androidx.lifecycle:lifecycle-livedata:2.0.0
|    |    |    |    |    +--- androidx.arch.core:core-runtime:2.0.0
|    |    |    |    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    |    |    |    |    \--- androidx.arch.core:core-common:2.0.0 (*)
|    |    |    |    |    +--- androidx.lifecycle:lifecycle-livedata-core:2.0.0
|    |    |    |    |    |    +--- androidx.lifecycle:lifecycle-common:2.0.0 (*)
|    |    |    |    |    |    +--- androidx.arch.core:core-common:2.0.0 (*)
|    |    |    |    |    |    \--- androidx.arch.core:core-runtime:2.0.0 (*)
|    |    |    |    |    \--- androidx.arch.core:core-common:2.0.0 (*)
|    |    |    |    \--- androidx.lifecycle:lifecycle-viewmodel:2.0.0
|    |    |    |         \--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    |    +--- androidx.localbroadcastmanager:localbroadcastmanager:1.0.0
|    |    |    |    \--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    |    \--- androidx.print:print:1.0.0
|    |    |         \--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    +--- androidx.fragment:fragment:1.0.0
|    |    |    +--- androidx.core:core:1.0.0 -> 1.0.1 (*)
|    |    |    +--- androidx.legacy:legacy-support-core-ui:1.0.0
|    |    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    |    |    +--- androidx.core:core:1.0.0 -> 1.0.1 (*)
|    |    |    |    +--- androidx.legacy:legacy-support-core-utils:1.0.0 (*)
|    |    |    |    +--- androidx.customview:customview:1.0.0
|    |    |    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    |    |    |    \--- androidx.core:core:1.0.0 -> 1.0.1 (*)
|    |    |    |    +--- androidx.viewpager:viewpager:1.0.0
|    |    |    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    |    |    |    +--- androidx.core:core:1.0.0 -> 1.0.1 (*)
|    |    |    |    |    \--- androidx.customview:customview:1.0.0 (*)
|    |    |    |    +--- androidx.coordinatorlayout:coordinatorlayout:1.0.0
|    |    |    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    |    |    |    +--- androidx.core:core:1.0.0 -> 1.0.1 (*)
|    |    |    |    |    \--- androidx.customview:customview:1.0.0 (*)
|    |    |    |    +--- androidx.drawerlayout:drawerlayout:1.0.0
|    |    |    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    |    |    |    +--- androidx.core:core:1.0.0 -> 1.0.1 (*)
|    |    |    |    |    \--- androidx.customview:customview:1.0.0 (*)
|    |    |    |    +--- androidx.slidingpanelayout:slidingpanelayout:1.0.0
|    |    |    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    |    |    |    +--- androidx.core:core:1.0.0 -> 1.0.1 (*)
|    |    |    |    |    \--- androidx.customview:customview:1.0.0 (*)
|    |    |    |    +--- androidx.interpolator:interpolator:1.0.0
|    |    |    |    |    \--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    |    |    +--- androidx.swiperefreshlayout:swiperefreshlayout:1.0.0
|    |    |    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    |    |    |    +--- androidx.core:core:1.0.0 -> 1.0.1 (*)
|    |    |    |    |    \--- androidx.interpolator:interpolator:1.0.0 (*)
|    |    |    |    +--- androidx.asynclayoutinflater:asynclayoutinflater:1.0.0
|    |    |    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    |    |    |    \--- androidx.core:core:1.0.0 -> 1.0.1 (*)
|    |    |    |    \--- androidx.cursoradapter:cursoradapter:1.0.0 (*)
|    |    |    +--- androidx.legacy:legacy-support-core-utils:1.0.0 (*)
|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    |    +--- androidx.loader:loader:1.0.0 (*)
|    |    |    \--- androidx.lifecycle:lifecycle-viewmodel:2.0.0 (*)
|    |    +--- androidx.vectordrawable:vectordrawable:1.0.1
|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    |    \--- androidx.core:core:1.0.0 -> 1.0.1 (*)
|    |    \--- androidx.vectordrawable:vectordrawable-animated:1.0.0
|    |         +--- androidx.vectordrawable:vectordrawable:1.0.0 -> 1.0.1 (*)
|    |         \--- androidx.legacy:legacy-support-core-ui:1.0.0 (*)
|    +--- androidx.annotation:annotation:1.0.1
|    +--- androidx.recyclerview:recyclerview:1.0.0
|    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.1
|    |    +--- androidx.core:core:1.0.0 -> 1.0.1 (*)
|    |    \--- androidx.legacy:legacy-support-core-ui:1.0.0 (*)
|    \--- it.sephiroth.android.library.imagezoom:library:1.0.4
|         \--- it.sephiroth.android.library.easing:library:1.0.2

修改后的依赖关系如下:

+--- com.zhihu.android:matisse:0.5.2-beta4
|    +--- com.android.support:support-v4:27.1.1 -> 28.0.0 (*)
|    +--- com.android.support:appcompat-v7:27.1.1 -> 28.0.0 (*)
|    +--- com.android.support:support-annotations:27.1.1 -> 28.0.0
|    +--- com.android.support:recyclerview-v7:27.1.1 -> 28.0.0 (*)
|    \--- it.sephiroth.android.library.imagezoom:library:1.0.4
|         \--- it.sephiroth.android.library.easing:library:1.0.2

还是有依旧不是最新的,但是没有影响,是被忽略了的(*)。

新的依赖查看:Gradle中就可以直接查看了

就没有了依赖冲突的解决方案提示了,但是我们还是可以直接查看依赖升级的建议:

 

升级的时的问题

不知大家手上有没有老项目,加点依赖总是感觉不兼容,加不进去?

这里还有一个级别高的依赖那就是项目依赖,我这里的gradle版本最开始是‘2.3.0‘加什么东西都可能不兼容,在我升级realm数据库版本的时候就出现了问题,我直接向realm升级到’5.14.0‘,发现它要求gradle 版本升级,于是我升级了,但是最新正式版本’3.5.0‘,编译ADIL会出问题(>.< ~~~~有大佬知道的吗,给个留言),我就退而求其次,选择’3.4.2‘。

建议(更新与2021.1.7):

1·老项目升级时,一点一点的升级,

2.遇到有api更改的,先退回

3.gradle版本要和 com.android.tools.build:gradle 同步一致

       这两个越高越好,特别是超低版本升级后,会发现编译时间极大的减少,但是项目会占用硬盘空间

       就我这旧电脑和 android 9 手机 而言

android studiogradlecom.android.tools.build:gradle打包第一次打包上手机
4.1.15.13.4.38 * 60s60s
4.1.16.54.1.03 m 19 s 629 ms41 s 128 ms
     
     

 像我说的我在一步步升级,升级到更高版本后我在来记录!

4.上一条应该和其他依赖分开来处理升级

5.关于android 或者 与android 库有关的依赖 最新版的不一定是最合适的(特别是android 到 androidx的变化)

顺便提一下 - 包冲突问题

如果之前项目中是将依赖源码下载,用module的方式依赖,而后面在某个地方再次使用配置的方式依赖进来(或者是依赖树中包含),在打包apk时会提示包冲突,所以要么删除这个module,要么忽略树依赖中的依赖。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值