Eclipse接入第三方动态库.so方案

在Android.mk中加入如下代码


####### third so begin

include $(CLEAR_VARS)

LOCAL_MODULE:= agora-rtc

LOCAL_SRC_FILES :=../prebuilt/$(TARGET_ARCH_ABI)/libagora-rtc-sdk-jni.so

include $(PREBUILT_SHARED_LIBRARY)


include $(CLEAR_VARS)

LOCAL_MODULE:= agoraSdkCWrwper

LOCAL_SRC_FILES := ../prebuilt/$(TARGET_ARCH_ABI)/libagoraSdkCWrapper.so

include $(PREBUILT_SHARED_LIBRARY)

####### third so end


### 定义头文件目录

LOCAL_C_INCLUDES :=    $(LOCAL_PATH)/../../Classes \

                                            $(LOCAL_PATH)/../../Classes/sdk/Agora \

                                            $(LOCAL_PATH)/../../Classes/sdk/Agora/include


### 引用第三方模块

LOCAL_SHARED_LIBRARIES := agora-rtc agoraSdkCWrapper




include $(CLEAR_VARS)                                清理变量信息

include $(PREBUILT_SHARED_LIBRARY)     预编译第三方库

LOCAL_MODULE     模块名称
LOCAL_SRC_FILES  模块文件
LOCAL_SHARED_LIBRARIES 引用第三方模块




用例:
Andorid.mk:

LOCAL_PATH :$(call my-dir)

####### third so begin


include $(CLEAR_VARS)    // 清理变量

LOCAL_MODULE:= agora-rtc   // prebuilt中的.so库

LOCAL_SRC_FILES :=../prebuilt/$(TARGET_ARCH_ABI)/libagora-rtc-sdk-jni.so  //完整路径

include $(PREBUILT_SHARED_LIBRARY) // ndk编译导入共享库


include $(CLEAR_VARS)

LOCAL_MODULE:= agoraSdkCWrapper

LOCAL_SRC_FILES := ../prebuilt/$(TARGET_ARCH_ABI)/libagoraSdkCWrapper.so

include $(PREBUILT_SHARED_LIBRARY)


include $(CLEAR_VARS)

LOCAL_MODULE:= jcore116

LOCAL_SRC_FILES := ../prebuilt/$(TARGET_ARCH_ABI)/libjcore116.so

include $(PREBUILT_SHARED_LIBRARY)


####### third so end


include $(CLEAR_VARS)


LOCAL_MODULE := cocos2djs_shared


LOCAL_MODULE_FILENAME := libcocos2djs


ifeq ($(USE_ARM_MODE),1)

LOCAL_ARM_MODE := arm

endif


LOCAL_SRC_FILES := hellojavascript/main.cpp \

                   ../../Classes/AppDelegate.cpp \

                   ../../Classes/sdk/wx/Android/JniManager.cpp \

                   ../../Classes/sdk/wx/Android/JSBindingAndroidWXManager.cpp \

                   ../../Classes/sdk/wx/Android/JSBindingAndroidRecorderManager.cpp \

                   ../../Classes/jsb/Android/AndroidNativeHttpClient.cpp \

                   ../../Classes/jsb/Android/JSBindingAndroidNativeHttpClient.cpp \

                   ../../Classes/sdk/Agora/AgoraManager.cpp \


LOCAL_C_INCLUDES :$(LOCAL_PATH)/../../Classes \

$(LOCAL_PATH)/../../Classes/sdk/Agora \

$(LOCAL_PATH)/../../Classes/sdk/Agora/include 


LOCAL_STATIC_LIBRARIES := cocos2d_js_static


LOCAL_SHARED_LIBRARIES := agora-rtc agoraSdkCWrapper jcore116


LOCAL_EXPORT_CFLAGS :-DCOCOS2D_DEBUG=2 -DCOCOS2D_JAVASCRIPT


include $(BUILD_SHARED_LIBRARY)


$(call import-module, scripting/js-bindings/proj.android)




工程配置文件:

Application.mk (编译架构 armeabi-v7a / armeabi-v8a / x86   通用架构: armeabi)

APP_STL := gnustl_static 


# Uncomment this line to compile to armeabi-v7a, your application will run faster but support less devices

APP_ABI := armeabi-v7a x86  // ABI使用的编译架构


APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char

APP_LDFLAGS := -latomic


USE_ARM_MODE := 1


ifeq ($(NDK_DEBUG),1)

  APP_CPPFLAGS +-DCOCOS2D_DEBUG=1

  APP_OPTIM := debug

else

  APP_CPPFLAGS += -DNDEBUG

  APP_OPTIM := release

endif

NDK编译自动生成结果:


注意:eclipse接入动态链接库流程, 选择对应的ANDROID架构编译好的.so文件放入prebuilt目录下, 修改android.mk文件, 启用Application.mk文件中的

APP_ABI指定NDK编译架构, 进行NDK编译生成到libs对应文件夹中,在进行JAVA环境的配置和调用即可。




相关推荐
©️2020 CSDN 皮肤主题: 岁月 设计师:pinMode 返回首页
实付 19.90元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值