title: CMake: Referencing a sibling native Android Library module from App code
body: <p>I have an Android Studio project with a general layout as follows:</p>
  
  <pre><code>Project/
   |
   +-- app/
   |  |
   |  +-- src/main/cpp/
   |  |  |
   |  |  +-- native-lib.cpp
   |  |  +-- CMakeLists.txt
   |  |
   |  +-- build.gradle
   |  +-- CMakeLists.txt
   |  |
   +-- sibling-lib/
   |  |
   |  +-- src/main/cpp/
   |  |  |
   |  |  +-- partA/CMakeLists.txt
   |  |  +-- partB/CMakeLists.txt
   |  |  +-- partC/CMakeLists.txt
   |  |
   |  +-- build.gradle
   |  +-- CMakeLists.txt
   |
   +-- build.gradle
   +-- settings.gradle
  </code></pre>
  
  <p><code>sibling-lib</code> is a third-party library comprised of multiple parts, each with separate sources and common headers, each of which is compiled into either a static or shared library, using the associated CMake file, and included as a subdirectory by the top-level library CMake file. Most of those parts are dependent on other parts.</p>
  
  <p>The goal is to compile and link the parts of <code>sibling-lib</code> into library files within an Android Library (.aar) and use those libraries from the native files within the main app (e.g. <code>native-lib.cpp</code>). I have been able to compile each of the parts as a static library, with the final part linked together as a shared library (using target_link_libraries() on that part), and then load the library from the app's Java code. However, when I try to call any of <code>sibling-lib</code>'s functions, I receive reference errors when compiling.</p>
  
  <p>How should I configure the CMake and gradle files (for both the app and library) to properly compile and set up my project? Is there, however, a better way to configure the project to obtain the desired result?</p>