I need to build a library with android studio and here is my configuration:
A project with 2 modules: 1/App: Application Module containing an application to test my library 2/MyLibrary: Library Module, containing the library i'm working on.
Each of these module has an implementation to the same external .jar library file (put in libs folder of each module) by going to project structure-> dependencies and adding libs folder which results in:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: [])
}
The fact i need the jar in the two modules is that i need some object from this jar library as a function argument in the library i'm writting, and therefore i need my test module to be able to provide this kind of object.
When i try to compile, i have an error saying "Type com..... is defined multiple times" and indeed the external library is visible two times in intermediates folder
It's obvious the problem comes from my way of implementing this external library. I need a way to implement it once, or avoid the two conflicting...
My Question: What is the good way of implementing an external library in two modules inside the same project?
What i already tried: -Clean project -Rebuild project -Invalidate cache -Delete intermediate folder -Check package names
There are several options: