I am trying to create an android library, moduleD, which depends on another library module, which in turn depends on two library modules. Everything seems to be building fine, but I get a ClassNotFoundException when I try to use the library in the application.
Customization
MyLibrary/ +-- moduleA +-- src/main/java/ +-- com/example/a +-- moduleB +-- src/main/java/ +-- com/example/b +-- moduleC +-- src/main/java/ +-- com/example/b +-- com/example/c `-- MyMissingClass.java <-- MISSING +-- moduleD +-- src/main/java/ +-- com/example/b
build.gradle (module C)
dependencies { compile project(':moduleA') compile project(':moduleB') }
build.gradle (module D)
dependencies { compile project(':moduleC') }
In my application, I call ModuleD, which calls Module
For completeness, I refer to the resulting Macs locally, but I don't think the problem is. When unpacking .jar classes in moduleD, I can see the files of the moduleD class, but not MyMissingClass.
build.gradle (in a separate application project)
repositories { ... flatDir { dirs 'libs' } } dependencies { compile(name:'moduleB', ext:'aar') }
non-decision
Transitive dependency [1] [2]
[1]: How to enable dependencies in android gradle library? [2]: How to send Android library (aar) using remote dependencies (gradle)?
build.gradle (application)
dependencies { compile(name:'moduleD', ext:'aar') { transitive true } }
This can work for external dependencies (for example, accessible through maven, both central and local), and it makes sense to avoid binding external dependencies, which otherwise could be updated / lowered independently, to avoid conflicts or get corrections. However, AC modules are internal to the project and are now used only in this library.
Question
Is it possible to create aar (or jar) for module D, which contains all the classes and can actually be used in the application if the library project is divided into separate modules?