Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is TARGET_ARCH_ABI set in Android.mk

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?

like image 642
shaveenk Avatar asked Feb 11 '16 19:02

shaveenk


People also ask

How does Android.mk work?

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.

What is Ndk_project_path?

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.

What is NDK build?

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.

What is Target_Arch_Abi in Android Studio?

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:

How does the Android system know which Abi (s) it supports?

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.

What is the Android build file used by ndk-build?

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.

How do I set ndk build path in Android?

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.


Video Answer


2 Answers

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
like image 167
Andre Romano Avatar answered Oct 17 '22 02:10

Andre Romano


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

like image 38
YLi Avatar answered Oct 17 '22 01:10

YLi