How to check dependencies between jar packages on Android and solve the problem of package conflicts, mother no longer has to worry

Sometimes, our project is too big, or we refer to external toolkits, open source jar packages or push and other jar packages, and we happily want to integrate it, but suddenly it comes, crashes, conflicts between jar packages, Common conflicts between different versions of the support-v4 package.

Gradle provides you to view the dependencies between libraries. Let's set up the environment first.

First, the configuration environment

The gradle version used in Android Studio is generally not the latest version, so it is easy to report the error of too low version when using its own Terminal. For convenience, I 
downloaded the latest version of gradle from the gradle official website, and then configured the gradle environment. variables for convenience.

2. gradle task related content

Gradle itself does not provide a command to view library dependencies. Fortunately, Android Studio provides tasks for viewing, which are located in the help task heap of each module, as shown below:

Figure 1

Figure II

Double-click dependencies to execute the task. You can see that no dependencies are obtained in the gradle console. The result is shown in the following figure:

Figure 3

It can be seen from the above figure that no matter which module we execute the dependencies under, the result is equivalent to executing the task in the Root project; what about executing the dependencies task in the app project or the test01library project? At this point, we need to execute dependencies through the command line.

After configuring the environment, first cmd enters the core module path of your current project, and tests: gradle dependencies In gradle 4.1, the dependencies are not printed, use gradle -q dependencies 就ok了

Because I used a lot of tools and open source tools when I built the framework, the conflict encountered here is that the support-v4 package conflicts with the support-v4 contained in other jar packages. The final solution:

To resolve package conflicts, the key is to see the dependencies between packages, which is a perfect solution to the problem.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325344955&siteId=291194637