Publishing an AAR containing native libraries is pretty straight-forward. Advantages I've found include:
- If using for multiple projects, of course there's a benefit in not duplicating the native code
- Application build is much faster, as you don't have to do the NDK compilation in the app. So if the native code changes less frequently
- In my case, there was an incompatibility with certain NDK and SDK combinations. Being able to build the library with an older SDK and the app with a newer version is working pretty well. (avoids having my app stuck on an older SDK version due to an NDK issue)
- can have unit tests against the library code that are completely independent of any including application. (Application unit tests can still test the library also)
Trade off is that there are a few extra steps to update the c-code, but if that changes less frequently than the app, then it's a good trade off.
It's worth noting that I get a warning: Current NDK support is deprecated. Alternative will be provided in the future.
on every build. AFAIK, the alternative isn't yet available - my definition of deprecated would be that it's not deprecated until that happens.
Here are the key points of how I have it working: