Reputation: 2140
I'm creating a .aar module that's dependent on another .aar file.
I'm adding the dependency to the project in my gradle file like so:
debugApi(group: 'com.mydomain.mylib', name: 'anotherlib-debug', version: '1.0', ext: 'aar') {
transitive=true
}
releaseApi(group: 'com.mydomain.mylib', name: 'anotherlib-release', version: '1.0', ext: 'aar') {
transitive=true
}
The transitive=true
doesn't seem to be working because when I build my .aar file the dependencies aren't included.
I have 2 questions:
1. How can I include the dependency .aar files so they build into my modules .aar file?
2. Can I build my modules .aar file so it doesn't expose the dependency .aar api in whatever project uses it? . That is, I would like to prevent someone who's using my module in their project from directly accessing the api from the dependency .aar file. I would like to only let them use the api I create that wraps or uses the dependency.
Upvotes: 2
Views: 2831
Reputation: 12573
transitive=true
does not help with including dependent aar. Upvotes: 0
Reputation: 569
AARs don't manage dependencies; maven does (typically via the pom.xml file alongside the AAR). You'll need to check the build process for these AARs to make sure they generate and deploy the pom files correctly.
As for the second question, gradle behaves this way if you replace debugApi
with debugImplementation
. If you're trying to extend this to anyone using the module, this is basically impossible since they can still depend on the dependency directly.
Alternatively (perhaps this was what you intended to ask in the first place), it's possible to compile library code and dependencies into a "fat" AAR which has no dependencies, and effectively hides its external dependencies. Note you are likely to get classpath issues if you also directly depend on the same dependencies in consuming code, so be careful. Android doesn't support this natively, but there are plugins which can help, such as https://github.com/adwiv/android-fat-aar
Upvotes: 1