Skip to content Skip to sidebar Skip to footer

Missing Dependency In Dependent Project

I have an android project with following structure: -- Calendar ------app (app module) ----------build.gradle (module level) ------build.gradle (project level) ------Commons(A comm

Solution 1:

There are two things at play here:

  1. The separation of api and implementation when declaring dependencies. In short dependencies in the implementation scope are only visible at runtime because they are an implementation detail. Such libraries will use the runtime scope in their published Maven metadata. More information in the documentation
  2. Before Gradle 5.0, the Maven metadata scopes compile and runtime were mixed by Gradle and thus all runtime dependencies did appear on the compile classpath. Gradle 5 changes this

So when you publish your component, the limitation of Gradle 4.x means that your common dependencies are available to app. Note that moving to Gradle 5 will cause a breakage there, as documented. And when you use the project directly, the separation is properly enforced.

The fix is to simply promote dependencies that are part of the common api to the api configuration in common and for the runtime ones, declare them in app as after all they are directly required by it.

Post a Comment for "Missing Dependency In Dependent Project"