"gradle dependencies" failing for android library module

Hi everyone,

I am having an issue with retrieving dependencies with gradle for one of my android library modules.

I have 3 modules in my android project:
application module
android library module 1 (mylibrary1)
android library module 2 (mylibrary2)

The application module has dependencies on both library projects:

implementation project(':mylibrary1')
implementation project(':mylibrary2')

and mylibrary2 has a dependency on mylibrary1:

implementation project(':mylibrary1')

When I run the gradle dependencies command for mylibrary2, the archives configuration fails to retrieve the transient dependencies of the dependent mylibrary1

so, the command:

gradle mylibrary2:dependencies --configuration archives  

fails with:

project :mylibrary1 FAILED

For the application module, everything works fine. And all other configurations for the mylibrary2 project are successful.

I was able to reproduce this in a brand new project setup, which doesn’t have anything special. Just created the 3 modules above and dependencies between them, so it’s not related to any custom implementation.

Does anyone know why this is happening? And also, what I can do to fix it?

Thank you!
Florentina

Hey Florentina,

can you push your reproducable example somewhere so we can take a look? which gradle version do you use?

cheers,
René

Hi René,

Thank you for replying. I pushed the example project here: https://github.com/arsinte/playground

I am using gradle 4.1

Florentina

I think the problem is that a android library module cannot depend on another android library module. You should probably factor out the common code from library one in a simple non library project and let both libraries depend on it.

change implementation to api or compile, you will get the right result

reference: [http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Why-Gradle-]

Thank you for the suggestion, however, this does not solve the problem.

  • compile was replaced by implementation in version 3.0.0 of the android plugin
  • I’ve tried using api, but it didn’t fix the issue, though, this seems the best fit for the setup I have

That was my thought too, but I thought maybe there’s something else that might be wrong with that implementation. I can’t apply your suggestion due to the design of the codebase, but it did give me an idea - I’ve changed the type of the dependency module (mylibrary1 from my example above) to a java only library. It seems that it didn’t really need to be an android library module.

So, I now have an application module, a java library module and an android module. The dependency between the android library module and the java library module works fine and the dependencies command succeeds.

Thank you for the help!