For various reasons I am in a situation where I have multiple app components existing in small isolated android-library projects, which are being compiled out as .aar
s.
In some cases these are pushed to a maven repo and consumed that way, which is fine and everything works great.
In other cases these aars need to be compiled into another android library. With my current config Im having issues as the child aar lib contents are not added to the parent aar lib project on gradlew assembleRelease
.
Dependency flow is like
Apk app project -> parentLibProject -*> childLibProject
This results in the parent aar compiling fine as the child aars are on the classpath but will not include the child aar libs contents in the output parent aar. This means any android application project which uses the parent lib will fail at compilation time as the child lib aar files/code are not in the parent aar. I do not want to go the route of forcing the app project to manually list all the child lib projects that have already been listed in the parent lib project. In essence I want to aars to be treated in a similar way to jar
libs that are used by a library project i.e. compiled into the output aar
.
I have tried a few non-successful approaches (which all build fine but all fail to output the child aar lib contents into the parent aar lib file):
- The compiled child
aar
inside/libs/
, which is on declared in the repository closure withflatDir { dirs 'libs' }
and imported to parent lib project withcompile(name:'someAarLib-x.y.z', ext:'aar')
. This compiles fine but the parent project will also need to include thesomeAarLib-x.y.z
aar andcompile(name:'someAarLib-x.y.z', ext:'aar')
. - Importing the child aar as modules as described in this answer https://stackoverflow.com/a/24894387/236743. This compiles fine but has the same problem as 1.
- Using the same approach as https://stackoverflow.com/a/33264652/236743 but with
*.aar
. This does not work at all (as commented elsewhere on SO)
I am using Gradle 2.3 and android plugin 1.2.1 at present.
For now I am doing it in a hacky way of pulling the classes.jar
s out of the child aar projects and putting the the parent lib project (as per https://stackoverflow.com/a/33264652/236743) as it just so happens that they dont use any xml resources so Im not losing anything in this case. But this is slightly time consuming and not very scalable / bit of manual work I dont want to do. Yes could automate this but im sure there is an offical way that I have just not stumbled across the correct config.
Many thanks for any help.