查看 gradle依赖关系,以及去除重复依赖包

1、如何查看 as 中 包之间的依赖关系

在这里插入图片描述
可以得到类似以下层级依赖关系

------------------------------------------------------------
Project :app
debugAndroidTestCompileClasspath - Resolved configuration for compilation for variant: debugAndroidTest
+--- com.android.support.test.espresso:espresso-core:2.2.2
|    +--- com.squareup:javawriter:2.1.1
|    +--- com.android.support.test:rules:0.5
|    |    \--- com.android.support.test:runner:0.5
|    |         +--- junit:junit:4.12
|    |         |    \--- org.hamcrest:hamcrest-core:1.3
|    |         \--- com.android.support.test:exposed-instrumentation-api-publish:0.5
|    +--- com.android.support.test:runner:0.5 (*)
|    +--- javax.inject:javax.inject:1
|    +--- org.hamcrest:hamcrest-library:1.3
|    |    \--- org.hamcrest:hamcrest-core:1.3
|    +--- com.android.support.test.espresso:espresso-idling-resource:2.2.2
|    +--- org.hamcrest:hamcrest-integration:1.3
|    |    \--- org.hamcrest:hamcrest-library:1.3 (*)
|    +--- com.google.code.findbugs:jsr305:2.0.1
|    \--- javax.annotation:javax.annotation-api:1.2
+--- com.tencent.tbs.tbssdk:sdk:43697
+--- project :liveplayer-sdk-ui
|    +--- com.android.databinding:baseLibrary:3.2.0
|    +--- com.android.databinding:library:3.2.0
|    |    +--- android.arch.lifecycle:runtime:1.0.3 -> 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:support-core-utils:26.1.0 -> 28.0.0
|    |    |    +--- com.android.support:support-annotations: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 (*)
|    |    |    |    \--- 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: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.databinding:baseLibrary:3.2.0
|    \--- com.android.databinding:adapters:3.2.0
|         +--- com.android.databinding:baseLibrary:3.2.0
|         \--- com.android.databinding:library:3.2.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-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-core-utils: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: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: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: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 (*)
+--- com.android.support:appcompat-v7:26.+ -> 28.0.0 (*)
+--- com.android.support:cardview-v7:26.+ -> 28.0.0 (*)
+--- com.squareup.retrofit2:retrofit:2.1.0
|    \--- com.squareup.okhttp3:okhttp:3.3.0 -> 3.4.1
|         \--- com.squareup.okio:okio:1.9.0
+--- com.squareup.retrofit2:converter-gson:2.1.0
|    +--- com.squareup.retrofit2:retrofit:2.1.0 (*)
|    \--- com.google.code.gson:gson:2.7
+--- com.squareup.retrofit2:adapter-rxjava:2.1.0
|    +--- com.squareup.retrofit2:retrofit:2.1.0 (*)
|    \--- io.reactivex:rxjava:1.1.5 -> 1.3.0
+--- com.squareup.okhttp3:logging-interceptor:3.4.1
|    \--- com.squareup.okhttp3:okhttp:3.4.1 (*)
+--- com.github.bumptech.glide:glide:4.8.0
|    +--- com.github.bumptech.glide:gifdecoder:4.8.0
|    |    \--- com.android.support:support-annotations:27.1.1 -> 28.0.0
|    +--- com.github.bumptech.glide:disklrucache:4.8.0
|    +--- com.github.bumptech.glide:annotations:4.8.0
|    \--- com.android.support:support-fragment:27.1.1 -> 28.0.0 (*)
+--- io.reactivex:rxandroid:1.2.1
|    \--- io.reactivex:rxjava:1.1.6 -> 1.3.0
+--- io.reactivex:rxjava:1.3.0
+--- org.greenrobot:eventbus:3.0.0
+--- me.everything:overscroll-decor-android:1.0.4
|    \--- com.android.support:recyclerview-v7:23.3.0 -> 28.0.0 (*)
+--- me.leolin:ShortcutBadger:1.1.18 -> 1.1.22
+--- :openDefault-4.3.0
+--- com.umeng.sdk:push:4.2.0
+--- com.android.support:multidex:1.0.3
+--- pub.devrel:easypermissions:0.4.3
|    \--- com.android.support:appcompat-v7:25.3.1 -> 28.0.0 (*)
+--- com.scwang.smartrefresh:SmartRefreshLayout:1.1.0-alpha-26
+--- com.scwang.smartrefresh:SmartRefreshHeader:1.1.0-alpha-26
+--- com.umeng.umsdk:analytics:8.0.0
+--- com.umeng.umsdk:common:2.0.0
+--- com.github.franmontiel:PersistentCookieJar:v1.0.1
|    \--- com.squareup.okhttp3:okhttp:3.1.2 -> 3.4.1 (*)
+--- com.tencent.mm.opensdk:wechat-sdk-android-with-mta:5.1.6
+--- com.davemorrissey.labs:subsampling-scale-image-view:3.5.0
|    \--- com.android.support:support-annotations:20.0.0 -> 28.0.0
+--- com.contrarywind:Android-PickerView:3.2.4
+--- me.leolin:ShortcutBadger:1.1.22
+--- com.github.devlight.shadowlayout:library:1.0.2
|    +--- org.jsoup:jsoup:+ -> 1.13.1
|    \--- com.android.support:appcompat-v7:23.3.0 -> 28.0.0 (*)
+--- project :gallery
+--- project :banner
+--- project :imagepagerlib
+--- project :imageslibrary
+--- com.github.heynchy:CompressImage:v0.1.2
+--- jp.wasabeef:glide-transformations:2.0.1
|    \--- com.github.bumptech.glide:glide:3.7.0 -> 4.8.0 (*)
+--- com.yanzhenjie:sofia:1.0.5
+--- com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.40
+--- project :citypicker
+--- com.jude:easyrecyclerview:4.4.2
+--- com.github.hackware1993:MagicIndicator:1.5.0
|    \--- com.android.support:appcompat-v7:23.4.0 -> 28.0.0 (*)
\--- com.android.support:support-annotations:27.1.1 -> 28.0.0

2、去除重复依赖包

在 build.gradle 文件中,使用 exclude

dependencies{
          implementation('com.afollestad.material-dialogs:commons:0.9.4.5') {
                 exclude group: 'com.android.support'
           }
}

具体情况可以具体分析

另附上一篇文章:

Android Gradle依赖管理、去除重复依赖、忽略的方式

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
回答: 在使用Gradle构建工具时,可以通过在build.gradle文件中的dependencies块中添加相应的依赖来引入ES(Elasticsearch)的Gradle依赖。根据提供的引用内容,可以看到以下几个示例: 1. 在build.gradle文件中使用exclude关键字来排除特定的依赖项,例如: ``` dependencies { implementation('com.afollestad.material-dialogs:commons:0.9.4.5') { exclude group: 'com.android.support' } } ``` 2. 在model1工程的build.gradle文件中,使用compile关键字添加ES的依赖项,例如: ``` dependencies { compile 'org.elasticsearch:elasticsearch:6.3.2' compile project(':tool1') } ``` 3. 在demo3工程的build.gradle文件中,同样使用compile关键字添加ES的依赖项,例如: ``` dependencies { compile 'org.elasticsearch:elasticsearch:6.3.2' compile project(':ToolCommon') } ``` 综上所述,根据不同的项目需求和依赖关系,可以在Gradlebuild.gradle文件中使用compile或implementation关键字来添加ES的Gradle依赖。 #### 引用[.reference_title] - *1* [查看 gradle依赖关系,以及去除重复依赖](https://blog.csdn.net/xzytl60937234/article/details/107406331)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [gradle依赖其他工程,平级or聚合](https://blog.csdn.net/xiaoxudong666/article/details/84105505)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值