gradle 依赖树_gradle依赖树

gradle 依赖树

Recently, in one of my projects, we were stuck at a very annoying exception IllegalStateException: WorkManager is already initialized . We were pretty confident on we have only initialized WorkManager only one time, then why Android Studio is throwing this exception.

最近,在我的一个项目中,我们陷入了一个非常烦人的异常IllegalStateException: WorkManager is already initialized 。 我们对只初始化WorkManager一次非常有信心,这就是Android Studio为什么抛出此异常的原因。

The initial hunch we had was there’s some other dependency in our project, which is using WorkManager and that’s why this conflict is popped up. We looked at the build.gradle file and realized that we haven’t added any such dependency in our project which might use WorkManager in any way.

我们最初的预感是项目中存在其他依赖项,这是使用WorkManager的原因,这就是为什么会弹出此冲突的原因。 我们查看了build.gradle文件,意识到我们没有在项目中添加任何可能以任何方式使用WorkManager依赖项。

Looking into different solutions like updating / removing dependencies, and plugins, and debugging the app line by line to see where and how it crashes, we simply couldn’t crack the problem. And that’s where it hit me suddenly.

研究不同的解决方案,例如更新/删除依赖关系和插件,以及逐行调试应用程序以查看崩溃的位置和方式,我们根本无法破解问题。 那就是它突然袭击我的地方。

Is it possible to view the whole dependency tree of our project?

是否有可能查看我们项目的整个依赖树?

Answer is yes. It is possible in Android Studio and even terminal too. This article is about different methods to see how you can view the whole dependency tree of your app.

答案是肯定的。 在Android Studio中甚至在终端中也可以。 本文介绍了有关如何查看应用程序的整个依赖关系树的不同方法。

Gradle依赖树如何为您提供帮助? (How Gradle Dependency Tree Can Help You?)

The Gradle Dependency Tree or Graph can tell you the about all the dependencies being used in your app in hierarchical way. It can help you with the version resolutions of same dependencies.

Gradle依赖关系树或图可以告诉您有关在应用程序中以分层方式使用的所有依赖关系的信息。 它可以帮助您使用相同依赖项的版本解析。

For example, your app is using Retrofit version 2.1 but there’s some other dependency in your app which is using Retrofit version 2.2. So, Android Studio will try to upgrade the dependency to the latest version i-e 2.2 for your whole project. Now, if there’s the big difference between old version and new version and require refactoring changes, this can be a problem for your app.

例如,您的应用程序使用的是Retrofit版本2.1,但您的应用程序中使用的是Retrofit版本2.2。 因此,Android Studio将尝试将依赖项升级到整个项目的最新版本,即2.2。 现在,如果旧版本和新版本之间有很大差异,并且需要重构更改,那么这可能是您的应用程序遇到的问题。

Gradle dependency tree can help you detect these kinds of issues. It can also help you in detecting the dependencies which are not being used directly in your app but rather these are being added by nested dependencies.

Gradle依赖关系树可以帮助您检测此类问题。 它还可以帮助您检测未在应用程序中直接使用的依赖项,而是由嵌套的依赖项添加的依赖项。

Now, let’s see different ways to view the Android app’s Gradle dependency tree or graph.

现在,让我们看看查看Android应用程序的Gradle依赖关系树或图形的不同方法。

1.通过Android Studio Gradle Pane

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值