我有一个Android应用程序项目依赖于两个本机库libA和libB。 libA依赖于libB,并且这两个库都是使用APP_STL:= gnustl_shared构建的。在尝试构建APK时会出现问题:
[2014-09-30 14:31:47 - Appname] Error generating final archive: Found duplicate file for APK: lib/armeabi/libgnustl_shared.so
Origin 1: /libA/libs/armeabi/libgnustl_shared.so
Origin 2: /libB/libs/armeabi/libgnustl_shared.so
如何在使用公共共享库(如libgnustl_shared.so)时配置这些库以正确构建/链接?
编辑: 我尝试了很多替代makefile设置,所以很难知道在这里发布什么,但我会尝试。 libA / jni和libB / jni中的Application.mk文件都包含:
APP_STL := gnustl_shared
APP_OPTIM := release
APP_ABI := armeabi-v7a armeabi
APP_PLATFORM := android-15
在libA / jni中,Android.mk文件包含:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := MyBase
LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/libMyBase.so
LOCAL_PRELINK_MODULE := true
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := Base
LOCAL_SRC_FILES := Base.cpp
LOCAL_C_INCLUDES := ../../../../LIBS/MyBase/pub/include
LOCAL_LDLIBS := -llog -ljnigraphics
LOCAL_SHARED_LIBRARIES := MyBase
LOCAL_CPP_FEATURES += rtti
LOCAL_CPP_FEATURES += exceptions
include $(BUILD_SHARED_LIBRARY)
在libB / jni中,Android.mk文件包含:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := MyMedia
LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/libMyMedia.so
LOCAL_PRELINK_MODULE := true
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := Media
LOCAL_SRC_FILES := Media.cpp media_jni.cpp
LOCAL_C_INCLUDES := ../../../../LIBS/MyBase/pub/include \
../../../../LIBS/MyMedia/pub/include
LOCAL_LDLIBS := -llog -ljnigraphics
LOCAL_SHARED_LIBRARIES := MyBase MyMedia
LOCAL_CPP_FEATURES += rtti
LOCAL_CPP_FEATURES += exceptions
include $(BUILD_SHARED_LIBRARY)
$(call import-module,LIBS/MyBase/jni)
MyBase和MyMedia是用C ++编写的两个本机库,不支持Java / JNI。 MyMedia依赖于MyBase。这两个库都依赖于强大的C ++库,例如gnustl_shared。