Using a library in multiple projects with import-module

You may often need to use a library in multiple projects. You can put the library in each of the project's jni folders and build them separately. However, it is troublesome to maintain multiple copies of the same library. For example, when there is a new release of the library and you want to update the library, you will have to update each copy of the library.

Fortunately, Android NDK provides a feature to allow us maintain a library module outside a NDK project's main source tree and import the module with simple commands in the Android.mk file. Let's discuss how to import a module in this recipe.

How to do it...

The following steps describe how to declare and import a module outside of a ...

Get Android Native Development Kit Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.