首先在jni下创建一个文件夹prebuilt然后将你要使用的so库添加进来
如下
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := fmod
LOCAL_SRC_FILES := $(LOCAL_PATH)/$(TARGET_ARCH_ABI)/libfmod.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../fmod/inc
include $(PREBUILD_SHARED_LIBRARY)
其中LOCAL_EXPORT_C_INCLUDES路径在
然后需要在jni/Android.mk中添加include $(LOCAL_PATH)/prebuilt/Android.mk
LOCAL_SHARED_LIBRARIES := fmod
我的jni/Android.mk如下
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) $(call import-add-path,$(LOCAL_PATH)/../../cocos2d) $(call import-add-path,$(LOCAL_PATH)/../../cocos2d/external) $(call import-add-path,$(LOCAL_PATH)/../../cocos2d/cocos) LOCAL_MODULE := cocos2dcpp_shared LOCAL_MODULE_FILENAME := libcocos2dcpp define walk $(wildcard $(1)) $(foreach e,$(wildcard $(1)/*),$(call walk,$(e))) endef ALLFILES = $(call walk,$(LOCAL_PATH)/../../Classes) FILE_LIST := hellocpp/main.cpp FILE_LIST += $(filter %.cpp,$(ALLFILES)) FILE_LIST += $(filter %.c,$(ALLFILES)) FILE_LIST += $(filter %.hpp,$(ALLFILES)) LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%) LOCAL_SRC_FILES += prebuilt/$(TARGET_ARCH_ABI)/libfmod.so LOCAL_SRC_FILES += prebuilt/$(TARGET_ARCH_ABI)/libfmodstudio.so FILE_INCLUDES := $(shell find $(LOCAL_PATH)/../../Classes -type d) LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes LOCAL_C_INCLUDES += $(LOCAL_PATH)/../fmod/inc # _COCOS_HEADER_ANDROID_BEGIN # _COCOS_HEADER_ANDROID_END # _COCOS_LIB_ANDROID_BEGIN # _COCOS_LIB_ANDROID_END include $(LOCAL_PATH)/prebuilt/Android.mk LOCAL_STATIC_LIBRARIES := cocos2dx_static LOCAL_SHARED_LIBRARIES := fmod include $(BUILD_SHARED_LIBRARY) $(call import-module,.) # _COCOS_LIB_IMPORT_ANDROID_BEGIN # _COCOS_LIB_IMPORT_ANDROID_END
原文链接:https://www.f2er.com/cocos2dx/340197.html