You should be able to exclude it like this:
exclude group: 'something', module: 'something'
So do this on the external library for all the things you're using that's causing a problem.
define multiDexEnable True in your build.gradle(app)
and also define in dependency in same build.gradle(app)
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.
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.