Component-based development using AndroidStudio3.0 and above versions found that indirectly dependent libraries reported an error and the corresponding Library could not be found
My project looks like this
|--moduleA
|--moduleB
|--moduleC
1 Depend on moduleA in the build.gradle file of moduleB:
implementation project(path: ':moduleA')
2 Depend on moduleB in the build.gradle file of moduleC:
implementation project(path: ':moduleB')
So moduleC indirectly depends on moduleA
But the class that uses moduleA in moduleC is directly compiled and error is not found
import also cannot import moduleA
Solution: Replace moduleB's dependency on moduleA with:
api project(path: ':moduleA')
The reason is that:
implementation: the dependency only acts on the current Module and is not publicly disclosed;
api: Depends on public disclosure, not only on the current module.