Situation is that I in my project use library A. I also import external library which also has itself a library A. So as you can assume, when I try to compile, I receive Multiple DEX files define error which means that there are duplications.
However, If I remove my library from the project, I cannot use its provided methods. And I cannot find how can I remove that library from the module.
Any suggestions?
define multiDexEnable True in your build.gradle(app)
and also define in dependency in same build.gradle(app)
You should be able to exclude it like this:
So do this on the external library for all the things you're using that's causing a problem.
From here: https://discuss.gradle.org/t/how-to-exclude-transitive-dependency/2119/2
Thank you guys for your suggestions. I didn't want to do as Michael suggested because I believe it is kind of useless (having multiple libraries with same purpose) (already knew this trick). I have tried Ядм Жцмдшдт answer, but couldn't succeed in compiling code completely. I have received various errors.
In the end I have solved my own issue. What I did:
Remove library from my main app libs folder. Remove dependancies if any in Android Studio (File -> Project Structure -> Dependencies (On module app) -> remove if any regarding your library. Clean project in Android Studio (Build -> Clean Project). Go to the module where my library A is. Go to that module build.gradle file and add following line in the dependencies cluster
Sync code and enjoy results.
TLDR I didn't have libraryA compiled in my external module but it threw me duplication error, that's where I was confused. By removing it from my main project and adding it to my module's compilations list solved the problem.