我有来自第三方的.a文件。如何在android studio中使用它?
请帮帮我。
答案 0 :(得分:1)
您无法在应用中直接使用.a
库。这些库是静态的,Android应用程序只允许您加载动态库。
但是您可以构建一个与静态库链接的动态库。你只需要为Android.mk添加几行就可以链接到这个静态库。将预先构建的.a
及其标题放在jni文件夹旁边的prebuild jni中。那你的Android.mk应该是这样的:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := YourStaticLib
LOCAL_SRC_FILES := ../prebuilt/your_static_lib_prebuild.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../prebuilt
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := DynamicLib
LOCAL_C_INCLUDES := $(LOCAL_PATH) \
$(LOCAL_PATH)/../prebuilt
LOCAL_SRC_FILES := your_src_file.cpp
LOCAL_LDLIBS := -llog
LOCAL_ARM_NEON := true
LOCAL_STATIC_LIBRARIES := YourStaticLib
include $(BUILD_SHARED_LIBRARY)