Android nested multi project dependency issues

Hi,

Well, I am new to Gradle world. And for this specific issue of mine, I have traversed StackOverflow threads extensively without no avail. In short, what I want is -

Suppose I have 3 projects namely - A(library project), B(library project), C

  • Project A is simple witout no dependencies.
  • Project B is dependent on project A
  • Project C is dependent on project B

So in B’s settings.graddle file -

include ‘:ProjA’
project(’:ProjA’).projectDir = new File(‘ProjADirectory’)

And in B’s main module’s build file-

dependencies {
compile project(’:ProjA’)
}
And everything works fine for B.

However, when I did similar for proj C (adding B as dependant) it tells me that “:ProjA” is not found. I understand that If I add “:ProjA” in C’s setting file, it will compile ok.

But I want the script to automatically resolve “:ProjA” as B is added as a dependency. Is it possible, somehow?

Hey,

project dependencies can only be used if all projects are build in one gradle build. This means you need one settings.gradle file (usually on the root level) declaring projects, A, B & C.

Now the transitive dependencies in B to A is resolved when building C.

1 Like

Thanks for your reply. I am already known to your explanation, but I didn’t want to add Proj-A in C’s settings file rather trying to find a way out so that A becomes automatically visible to C’s context. However, I now like to add it programmatically from in B’s build file so eventually C will automatically get it. I guess I will need to open a new post for that.

Regards.