Compile standalone binaries with NDK 13
<p>With NDK 10 releases, I used to use <code>ndk-build</code> to compile standalone binaries for many different ABIs and multiple API levels. These binaries were to be included in an app. However, I installed the NDK on a new development machine as <a href="https://developer.android.com/ndk/guides/index.html#download-ndk" rel="noreferrer">described in this article</a>. This resulted in a folder <code>ndk-bundle</code> within my Android SDK directory. I used to compile the code from a command line and then copy the binaries to the resources of my Android Studio project, but I could not figure out how to do this with NDK 13 so I tried to follow <a href="https://developer.android.com/ndk/guides/index.html#native-project" rel="noreferrer">the tutorial to include my native code in the Android Studio project</a>. However, almost all recent instructions assume that one wants to build a library, not a standalone binary, so I did not get far.</p>

<p>I would switch to CMake if I figured out how to get it to work. My native project has the following (simplified) structure:</p>

<ul>
<li><p>native</p>

<ul>
<li><p>Android.mk</p>

<pre><code>LOCAL_PATH := $(call my-dir)/my_tool/src
include $(CLEAR_VARS)
LOCAL_MODULE    := my_tool
LOCAL_SRC_FILES := main.c
include $(BUILD_EXECUTABLE)
</code></pre></li>
<li><p>Application.mk</p>

<pre><code>APP_ABI := all
APP_PLATFORM := android-21
</code></pre></li>
<li><p>my_tool</p>

<ul>
<li>src

<ul>
<li>main.c</li>
</ul></li>
</ul></li>
</ul></li>
</ul>

<p>How can I compile this using either Android Studio or the NDK from the command line on our Windows 10 development machines?</p>

<p><strong>Edit:</strong></p>

<p>I am using this in build.gradle:</p>

<pre><code>externalNativeBuild {
    ndkBuild {
        path "../native/Android.mk"
    }
}
</code></pre>

<p>Gradle creates a directory <code>.externalNativeBuild</code> which contains build configurations, but I cannot find out how to actually build the native code. No binaries are created when I run gradle.</p>

<p>I cannot find <em>any</em> information about gradle configuration for <code>ndk-build</code>.</p>