Explain the transition dependency strategy described in the Android Build System documentation

Can someone explain what the Android tools command means in this short paragraph below?

In particular: What is "somelib.jar"?

They suggest that I create a new subproject that has only dependencies, name it "projectA" and then publish the project "projectA.jar"? (using artifacts.add ("default", file ('projectA.jar))

The supposed behavior I want is to publish "projectA.jar" along with its dependencies without causing "multiple dex file" errors.

http://tools.android.com/tech-docs/new-build-system/tips#TOC-Handling-transitive-dependencies-for-local-artifacts-jars-and-aar-

Quote:

If you have a local library or an arrangement library that you want to use in more than one project, you cannot just refer to it as a local dependency. This is because the Android plugin will complain if it finds the same jar file twice when developing a project and all its dependencies. (Note: right now you cannot use the local aar file, even if you only link once).

One way to fix this is to deploy the artifact to the repository. While possible, this may not be convenient due to the overhead of managing such a repository.

Another option is to create a new Gradle sub-project and make it the project published artifact is a jar or aar file that you want to reuse. Then you can just use other Gradle subprojects, this new subproject.

In this new subproject, just create build.gradle using the following:

configurations.create ("default")

artifacts.add ("default", file ('somelib.jar'))

+5
source share
1 answer

In my opinion, this is mainly used for the library module.

If one library module depends on somelib.jar , another application module, which depends on the library module, also depends on somelib.jar , then errors with several dex files may appear.

According to Tips, the problem can be solved by creating a simple module that cannot publish *.jar or *.aar and only for use by other modules , with only *.jar s dependency. In this case, the output of the *.aar library module will not contain somelib.jar .

0
source

Source: https://habr.com/ru/post/1201574/


All Articles