With NDK 10 releases, I used to use ndk-build
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 described in this article. This resulted in a folder ndk-bundle
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 the tutorial to include my native code in the Android Studio project. However, almost all recent instructions assume that one wants to build a library, not a standalone binary, so I did not get far.
I would switch to CMake if I figured out how to get it to work. My native project has the following (simplified) structure:
native
Android.mk
LOCAL_PATH := $(call my-dir)/my_tool/src include $(CLEAR_VARS) LOCAL_MODULE := my_tool LOCAL_SRC_FILES := main.c include $(BUILD_EXECUTABLE)
Application.mk
APP_ABI := all APP_PLATFORM := android-21
my_tool
- src
- main.c
- src
How can I compile this using either Android Studio or the NDK from the command line on our Windows 10 development machines?
Edit:
I am using this in build.gradle:
externalNativeBuild {
ndkBuild {
path "../native/Android.mk"
}
}
Gradle creates a directory .externalNativeBuild
which contains build configurations, but I cannot find out how to actually build the native code. No binaries are created when I run gradle.
I cannot find any information about gradle configuration for ndk-build
.
ndk-build
andCMake
). – Redvers