MarkoSelakovic
MarkoSelakovic

Reputation: 51

Gradle: app does not see code imported from second level of submodule

I have a problem with transitive dependencies in my project. There is an app (main) module which includes gradle library module A, which includes module B.

The problem is that app does not see classes inside module B. Module A of course see classes from B, but app does not.

Dependencies should be transitive by default, but nothing happens.

So app gradle file has:

implementation project(path: ':A')

Module A has:

implementation project(path: ':B')

If I add: implementation project(path: ':B') to the app gradle file, it works, but i must exclude this, since I will use product flavors and this does not works for me anymore.

Is there any workaround for this issue?

Upvotes: 2

Views: 371

Answers (1)

Nabin Bhandari
Nabin Bhandari

Reputation: 16409

If you use implementation, the classes won't be accessible from the modules which use it.

In order to expose the classes from sub-modules, you should replace implementation with api

In module 'A', use:

api project(':B')

In module 'app', use:

implementation project(':A')

Upvotes: 4

Related Questions