Another question about aars, library publishing an...
# android
c
Another question about aars, library publishing and 3rd party dependencies. I have an android lib/aar that I'm deploying to prod and currently we're self hosting the library. This means consumers of the lib need to add an additional maven repository declaration. This works nicely, BUT we use another 3rd party/partner which also requires an additional maven repository declaration for their android lib/aar. So basically in order to use our library you need to add two additional maven repo configs. What are my ways around this? Off the top of my head 1. somehow bundle the 3rd party aar INTO our app aar (i think i looked into this in the past and it wasn't possible?) 2. host the 3rd party dep in our maven repo (sounds like the easiest) 3. get us and the 3rd party to be on mavenCentral() (unlikely... for reasons, but technically a solution) What really throws me in a loop (sorry not a library dev) is that if I just put my library aar into a new project directly... it seems to be able to consume the aar directly without the 3rd party and it builds just fine.
p
Correct, is the way it works, gradle can't do anything for your aar if it doesn't have a POM.xml file that gradle can look into for your aar 3rd dependencies. Only when you properly publish your library with a pom.xml files and other metadata. Gradle can do stuff for you
If you just hand an aar/jar to your client, then you should indicate in your library documentation what are the 3rd party libs your lib consumes, in order to not have a runtime crash due to missing class exceptions
c
ooooooh. okay. so it will build fine, but will crash due to missing classes. okay. i unfortunately can't test that "partner" capability because its deep in the leaf nodes of the app that i cant access (for reasons 🤷 ) glad to know it's working as expected! ❤️
are my 3 options for paths forward correct (just want to sanity check my understanding as a lib publishing noob)? i really want to try the route of bundling the 3rd party aar into our aar.
t
I would probably pick option 2
p
Yes. 1 is not possible. Best you can do is 2 and 3. Basically the same. I prefer 2 as well. If the 3rd party you use need a special dependency, then include it in your pom.xml and that way your clients don't need to add anything. But if you tested it and all was good, then nothing else to do.
c
thanks. 1 not possible is a bit heartbreaking. but what can ya do. sounds like on jar side of things you can make "fat" jars? i guess thats not possible with aars.
looks shiny and new
t
fat aar is possible but risky
too many tradeoffs to be worth it imo
👍 1
c
@TrevJonez by fat aar do you mean the "fused library" above? or something different?
t
something different. fused library is worth a shot
p
The fused-library is for modules with source code in your library project. I am not aware you can include already compiled .aars
➕ 1
Fat aar is possible in pure jar libraries not aars. Precisely the assets Android specifics aspect, is what makes this process of bundling aars challenging
But yeah give it a try
c
not looking good for me 😅
😄 1