title: Android NDK - building native libraries without Android Studio
body: <p>I'm working on a c/c++ cross-platform project, constructed of 2 main libraries (with a few external dependencies: ssl, yajl, fribidi).<br>
  The android solution will include Java files and a JNI layer, all bundled in a AAR file (including assets and the native libs).  </p>
  
  <p>I managed to build the whole project, but in a very awkward way:<br>
  I created a 'hello world' Android app', with native support, from within Android Studio, and added all native dependencies to the CMAkeList.txt. I added my Java code + JNI and managed to create the AAR (only for ARM, for now).  </p>
  
  <p>Now I need to separate the build of the different libraries, to their separate projects, respectively: libA, libB and C.aar.  </p>
  
  <p><strong>How is it done without the IDE (and via command-line)?</strong><br>
  There's the <strong>stand-alone NDK</strong>, the <strong>make_standalone_toolchain.py</strong> script, <strong>android.toolchain.cmake</strong> and other options, but none are documented or up-to-date. Most documentation still talks about the outdated Android.mk methodology.<br>
  I'd presume including   <strong>android.toolchain.cmake</strong> in my CMakeList.txt, which will set all needed environment...</p>
  
  <p>I'm using the newest Android Studio 3.0.1 and NDK r16b (installed via SDK Manager)</p>
  
  <p>Alex - thanks, exactly what I was looking for. Just had to add a few flags and a call to make:  </p>
  
  <pre><code>&gt; cmake -G "MinGW Makefiles" -DCMAKE_TOOLCHAIN_FILE=%ANDROID_NDK%\build\cmake\android.toolchain.cmake -DANDROID_NATIVE_API_LEVEL=android-19 -DCMAKE_MAKE_PROGRAM=%ANDROID_NDK%\prebuilt\windows-x86_64\bin\make.exe -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI="armeabi-v7a with NEON" ..
  &gt; cmake --build .
  </code></pre>