首先,您需要为所有平台编译的 .a 文件。你可以在这里找到它https://github.com/gcesarmza/curl-android-ios或自己编译。然后您还需要添加为依赖项
"targets": [
{
"target_name": "libapplication_jni",
"type": "shared_library",
"dependencies": [
"../support-lib/support_lib.gyp:djinni_jni",
],
"libraries": ["libcurl.a",],
"ldflags": [ "-llog", "-lz", "-Wl,--build-id,--gc-sections,--exclude-libs,ALL" ],
"sources": [
"../support-lib/jni/djinni_main.cpp",
"<!@(python glob.py generated-src/jni '*.cpp')",
"<!@(python glob.py handwritten-src/cpp '*.cpp')",
],
"include_dirs": [
"../deps/include",
"generated-src/jni",
"generated-src/cpp",
"handwritten-src/jni",
"handwritten-src/cpp",
],
},
],
将 curl 包含文件放在 deps/include 目录中最后,将其放在 Android.mk 文件的开头
LOCAL_PATH:= $(call my-dir)
#ARM optimizations
ifeq ($(TARGET_ARCH),arm)
PLATFORM_TARGET_ARCH := armeabi
endif
ifeq ($(TARGET_ARCH),arm64)
PLATFORM_TARGET_ARCH := arm64-v8a
endif
#x86 optimizations
ifeq ($(TARGET_ARCH),x86)
PLATFORM_TARGET_ARCH := x86
endif
ifeq ($(TARGET_ARCH),x86_64)
PLATFORM_TARGET_ARCH := x86_64
endif
#MIPS optimizations
ifeq ($(TARGET_ARCH),mips)
PLATFORM_TARGET_ARCH := mips
endif
ifeq ($(TARGET_ARCH),mips64)
PLATFORM_TARGET_ARCH := mips64
endif
include $(CLEAR_VARS)
LOCAL_MODULE:= libcurl
LOCAL_SRC_FILES := /djinni/mobile/deps/prebuilt/android/$(PLATFORM_TARGET_ARCH)/libcurl.a
LOCAL_EXPORT_C_INCLUDES := /djinni/mobile/deps/include
include $(PREBUILT_STATIC_LIBRARY)
我希望它有帮助。谢谢