I am new to stackoverflow so I am sorry if my question is not perfectly explained.
My current project has the next structure
core Library
| |
Library 1 Library 2
| |
applications applications
Core Library is a library which contains common functionality for the other 2 libraries.
In this case core Library, Library 1 and 2 use Dependency injection with Dagger 2, and each one of them creates it's own dependency graph. So each one of them has it's own component interface, modules, and Dagger 2 generated classes. Also all of them have @Inject annotations for obtaining their required object instances.
core library uses 2 classes to make the connection with the other libraries. An initializer class which builds the dependency graph and a publisher class which has get methods that return the required object instances.
What I want to accomplish is to make 3 aar files, one for each library. And that Library 1 and 2 use the core Library aar. The applications take the library 1 and 2 from an artifactory repository.
My current problem is that in any of the 3 aar files are the Dagger 2 generated classes. I am not sure why. All the classes are been generated when I build the projects but the compiled classes are not inside the aar file.
I am using:
apt 'com.google.dagger:dagger-compiler:2.5'
compile 'com.google.dagger:dagger:2.5'
provided 'javax.annotation:jsr250-api:1.0'
gradle-2.14.1
This is an example of my publisher:
public class Publisher {
@Inject
ReceiversManager receiversManager;
@Inject
NetworkManager networkManager;
@Inject
HttpRequestManager httpRequestManager;
public ReceiversManager getReceiversManager(){
return receiversManager;
}
public NetworkManager getNetworkManager() {
return networkManager;
}
public HttpRequestManager getHttpRequestManager() {
return httpRequestManager;
}
public Publisher(){
Initializer.getComponent().inject(this);
}
}
I solved the problem with this script https://github.com/adwiv/android-fat-aar
That script helps to create an aar with dependencies included which can come very handy in many situations.