My use case is the following:
- I have an aar library (lets say L1) provided to me by a third party. Please note that I don't have the source for this.
- I want to write a wrapper layer on top of L1 and create another aar (SDK) (lets say L2). L1 should be packaged inside L2. Please note that the code in L2 is minimal, it is just like a wrapper for L1.
- The idea is that if someone integrates this SDK into their Android application, the application should only be interacting with L2, it should not even need to know that L1 exists. Basically, I want that in the application gradle file, only L2 should be included.
My question is whether this is possible? I looked at some similar questions on stack overflow - I got the following possible solutions - but none of them seemed suitable:
- Use android-fat-aar plugin - From what I understand, this plugin does not work with the latest gradle versions and is no longer actively maintained. I am using Android Studio Version 3.3.1 and gradle version 4.10.1. I think it also has some other limitations of not working well in case of aidl files.
- Some answers seemed to indicate to publish the aar to some repository like maven, in which case this would get resolved. I am not exactly sure if I understood that correctly, but in any case, publishing either L1 or L2 to any public repository is not an option for me.
So again to reiterate basic requirements are:
- The application should only call APIs of and interact with L2.
- The application should only need to include depencency of L2 in its gradle file?
Is there any way to achieve it given the constraints I mentioned - it doesn't necessarily have to be via merging aars.
Is the following possible / does it make any sense:
- Write the code needed for L2 and create a jar out of it
- Extract L1 aar (since aar is basically an archive)
- Add the jar created in step 1 above and create a new aar (lets say L3) which includes L2 APIs.
- The application now needs to add as dependency and interact with only one dependency L3 (which will have L2 APIs).