I am trying to build my native application using ndk-build. Suppose I followed this guide to create my Android project:
https://rathodpratik.wordpress.com/2013/03/24/build-cc-executables-for-android-using-ndk/
When I try to print out my TARGET_ARCH_ABI, I always get armeabi. Even if I explicitly set
TARGET_ARCH_ABI := armeabi-v7a
The application always builds into the libs/armeabi directory and when I check the elf header, it does in fact show that it has built for ARM.
How can I get it to build for armeabi-v7a?
The syntax of the Android.mk allows you to group your sources into modules. A module is either a static library, a shared library, or a standalone executable. You can define one or more modules in each Android.mk file, and you can use the same source file in multiple modules.
NDK_PROJECT_PATH - the location of your project NDK_APPLICATION_MK - the path of the Application.mk file APP_BUILD_SCRIPT - the path to the Android.mk file. These are needed to override the default values of the build script, which expects things to be in the jni folder.
To compile and debug native code for your app, you need the following components: The Android Native Development Kit (NDK): a set of tools that allows you to use C and C++ code with Android. CMake: an external build tool that works alongside Gradle to build your native library.
The TARGET_ARCH_ABI variable in the Android.mk file can point the build system at the appropriate version of the library. For example, assume that your project contains two versions of library libfoo.so: The following snippet shows how to use TARGET_ARCH_ABI so that the build system selects the appropriate version of the library:
The Android system knows at runtime which ABI (s) it supports, because build-specific system properties indicate: The primary ABI for the device, corresponding to the machine code used in the system image itself. An optional, secondary ABI, corresponding to another ABI that the system image also supports.
This page describes the syntax of the Android.mk build file used by ndk-build. The Android.mk file resides in a subdirectory of your project's jni/ directory, and describes your sources and shared libraries to the build system. It is really a tiny GNU makefile fragment that the build system parses once or more.
Set the NDK build system to use the appropriate build script for the module, using the BUILD_XXX variable. This variable is used to give the path of the current file. You must define it at the start of your Android.mk file.
Same problem but i actually managed to fix it, i restricted my build.gradle(module) to build only for certain abi, with:
defaultConfig {
ndk {
abiFilters 'armeabi-v7a'
}
}
and Application.mk:
API_ABI := armeabi-v7a
I had the exact same problem and I couldn't locate the cause either. However, I fixed it by putting:
TARGET_ARCH_ABI := armeabi-v7a
at the very beginning of Android.mk.
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With