I have Android apps A and B. I want to extract duplicate code from each into a shared library L. How can I do this using Gradle? I've seen a few permutations of this question asked before, but there were very few answers.
The closest/best already-asked question is this one:
Multiple Android apps depending on android library with gradle
The first answer suggests a parent project that encompasses both apps and the library module. This coupling is undesirable, in part because A, B, and L are in their own Git repository, but also because it would involve having a parent project and build files that would be difficult to put in source control (or would involve manual copying of the other projects). Since Android Studio likes a parent build for single-module projects by default...Well, it's just a lot of parents for what should be a simple family. It really seems like an unecessary coupling between projects that are otherwise completely unrelated.
The second answer involves releasing an AAR to a repo and referencing the remote library in each project. I would be fine with this approach as we have a local Nexus repository, but there does not seem to be a simple way to do this without manually versioning/naming and uploading files (this is unsustainable). I'm trying to use the Sonatype gradle-release plugin, but it seems to be for JARs (not AARs).
It just seems like a lot of moving parts for what amounts to the most basic form of code sharing between Android apps. Does anyone have a better solution?