在 android ndk 如何在一次构建中创建多个库 (.so) 运行

In android ndk how to create multiple library(.so) at one build run

如何在单个 ndk-build 中创建多个 .so 文件或库 运行 例如我已经发布了我的代码:

build.gradle:

ndk {
moduleName = [“native-lib”,”MyLibrary”]
}

sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir “src/main/libs”
}

Android.mk:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := native-lib
LOCAL_MODULE := MyLibrary
LOCAL_SRC_FILES := native-lib.cpp
LOCAL_SRC_FILES := MyLibrary.cpp
include $(BUILD_SHARED_LIBRARY)

Application.mk:

APP_MODULES := native-lib
APP_MODULES := MyLibrary

APP_ABI := all

这是可以做到的还是有任何其他方法可以做到这一点。谢谢

您需要在 Android.mk 中拆分内容:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := native-lib
LOCAL_SRC_FILES := native-lib.cpp
include $(BUILD_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := MyLibrary
LOCAL_SRC_FILES := MyLibrary.cpp
include $(BUILD_SHARED_LIBRARY)

Application.mk 中不需要 APP_MODULES。构建系统将默认构建 Android.mk.

中的所有模块