做项目的过程中发现,引用第三方的库lib3rdsdk.so,当直接把lib3rdsdk.so放进armeabi文件夹里,会被删除掉。查网上资料都说的不全,经过实验,最简单的方法就是在jni下的android.mk里加下面3-7行就可以,要放最前面,放后面有可能不行哦,因为编译路径有可能会被改掉。
其中prebuilt/$(TARGET_ARCH_ABI)中的prebuilt就是jni里新建的prebuilt文件,其实建不建无所谓,prebuilt里面有4个文件夹:armeabi、armeabi-v7a、mips、x86,每个文件夹里放着不同架构的lib3rdsdk.so库, $(TARGET_ARCH_ABI)则是按cpu架构自动选择armeabi、armeabi-v7a、mips、x86这些架构中的库,默认只会复制armeabi中的libtxpay.so库,比如需要多复制armeabi-v7a中的库,则需要在application.mk中添加APP_ABI := armeabi armeabi-v7a后,则会同时复制armeabi armeabi-v7a的库
01 |
LOCAL_PATH := $(call my-dir) |
02 |
03 |
include $(CLEAR_VARS) |
04 |
05 |
LOCAL_MODULE := 3rdsdk |
06 |
07 |
LOCAL_SRC_FILES := prebuilt/$(TARGET_ARCH_ABI)/lib3rdsdk.so |
08 |
09 |
include $(PREBUILT_SHARED_LIBRARY) |
10 |
11 |
include $(CLEAR_VARS) |
12 |
13 |
LOCAL_MODULE := game_shared |
14 |
15 |
LOCAL_MODULE_FILENAME := libgame |
16 |
17 |
#traverse all the directory and subdirectory |
18 |
19 |
define walk |
20 |
21 |
$(wildcard $( 1 )) $(foreach e, $(wildcard $( 1 )/*), $(call walk, $(e))) |
22 |
23 |
endef |
24 |
25 |
#traverse Classes Directory |
26 |
27 |
ALLFILES = $(call walk, $(LOCAL_PATH)/../../Classes) |
28 |
29 |
FILE_LIST := hellocpp/main.cpp |
30 |
31 |
FILE_LIST += $(LOCAL_PATH)/../../Classes/helloworld.cpp |
32 |
33 |
FILE_LIST += $(filter %.cpp, $(ALLFILES)) |
34 |
35 |
FILE_INCLUDES := $(shell find $(LOCAL_PATH)/../../Classes -type d) |
36 |
37 |
#source file will be compiled |
38 |
39 |
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%) |
40 |
41 |
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../external/Box2D/ \ |
42 |
43 |
$(FILE_INCLUDES) \ |
44 |
45 |
46 |
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static cocosdenshion_static cocos_extension_static box2d_static |
47 |
48 |
include $(BUILD_SHARED_LIBRARY) |
49 |
50 |
$(call import -module,CocosDenshion/android) \ |
51 |
52 |
$(call import -module,cocos2dx) \ |
53 |
54 |
$(call import -module,extensions) \ |
55 |
56 |
$(call import -module,external/Box2D) |
时间: 2024-10-07 22:27:05