About jni compiling 32-bit and 64-bit dynamic libraries (Android. mk and Application. mk files), jniapplication. mk
The latest new project needs to compile a 64-bit dynamic library, which records how to configure it.
Add the Android. mk and Application. mk files to the jni directory.
Application. mk
1 APP_ABI := armeabi armeabi-v7a arm64-v8a
Android. mk
1 LOCAL_PATH := $(call my-dir)2 include $(CLEAR_VARS)3 4 LOCAL_MODULE := hello-jni5 LOCAL_SRC_FILES := hello-jni.c6 7 include $(BUILD_SHARED_LIBRARY)
After these two mk files are added, the compilation will generate the library file of armeabi, armeabi-v7a, arm64-v8a.
Supplement:
Android. mk files are used to describe your source files to build system (compile system). For example, you need to compile a static library (. a file) or a dynamic library (. so file), which will be parsed once or multiple times by build system.
Application. mk is part of GNU Makefile and describes the modules (static or dynamic libraries) in the compilation system on which your Application depends ).
In the Android. mk file, determine whether the value is 64-bit or 32-bit.
1 ifneq ($(filter $(NDK_KNOWN_DEVICE_ABI64S),$(TARGET_ARCH_ABI)),) 2 # 64-bit ABIs 3 4 …… 5 …… 6 7 else 8 # 32-bit ABIs 9 10 ……11 ……12 ……13 14 15 endif
Compilation target type
Each Android. mk file will be followed by a description of the type of output to be compiled, for example:
Compile dynamic library: include $ (BUILD_SHARED_LIBRARY)
Compile static library: include $ (BUILD_STATIC_LIBRARY)
Output the compiled so file: include $ (PREBUILT_SHARED_LIBRARY)
Compile the jar file: include $ (BUILD_JAVA_LIBRARY)
Output the compiled apk file: include $ (BUILD_PREBUILT)
Compile the apk file: include $ (BUILD_PACKAGE)