包括一个从Eclipse上的JNI类调用的库--Android

时间:2015-03-26 15:44:00

标签: android android-ndk java-native-interface

在放置在jni文件夹下的CPP文件以及头文件和Android.mk中,我必须使用来自第三方库的API。图书馆提供商给了我两个文件:

RemoteDesk.h libremotedesk_client.so

我该如何包含这两个文件? Android.mk文件应该如何显示?

1 个答案:

答案 0 :(得分:0)

您需要从 Android.mk 中引用此预建库。

我认为您的供应商的lib是针对armeabi架构的,因此将 libremotedesk_client.so 放在 ./ jni / RemoteDeskLib / prebuilts / armeabi / 下。你应该问他更多,因为NDK还支持 armeabi-v7a x86 x86_64 arm64-v8a mips mips64 ...

同样将 RemoteDesk.h 放在 ./ jni / RemoteDeskLib / include 下:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := remotedesk_client
LOCAL_SRC_FILES := RemoteDeskLib/prebuilts/$(TARGET_ARCH_ABI)/libremotedesk_client.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/RemoteDeskLib/include/
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := yourLib
LOCAL_SRC_FILES := yourCppSourceCode.cpp
LOCAL_SHARED_LIBRARIES := remotedesk_client
include $(BUILD_SHARED_LIBRARY)