Reputation: 586
I have made many tiny projects so far such as single screen, quiz app, musical structure etc... As a newbie, I was looking for reusability of project as there are many packages those are same in all projects such as utils etc... So, I came to know about Android library module from below link:
https://developer.android.com/studio/projects/android-library
My problem is, even after adding dependencies in library module, why do I have to add same dependencies in app module also? E.g., my library module is using edmodo android image cropper (https://github.com/ArthurHub/Android-Image-Cropper) for image cropping and in order to use that in app module, I had to add its dependency in app module also! Why? Can it be improved? Thanks in anticipation!
Upvotes: 3
Views: 2065
Reputation: 24907
why do I have to add same dependencies in app module also?
This is because dependencies are not shipped along with your .aar/.jar
file. The compile time binding exists, due to which your library compiles, but in order to have runtime implementation, you need to include those libraries in your app module.
Can it be improved?
Can do that but ideally you should let the app module provide the dependencies. This is because, if two libraries ship with their dependencies, which could be used by both, then the common dependencies would be duplicated and overlap each other. This will cause build issues.
If you still want to proceed (may be you have internal module which is proprietary) then you can either extract the dependency libraries jar and include it in libs
directory or publish it in maven along with the dependencies.
Upvotes: 3