Android Studio 3.0.1不会构建NDK静态库

仓廪实则知礼节,衣食足则知荣辱。这篇文章主要讲述Android Studio 3.0.1不会构建NDK静态库相关的知识,希望能为你提供帮助。
【Android Studio 3.0.1不会构建NDK静态库】我正在尝试在我的android Studio项目中构建并包含一个静态库。我的项目在没有静态库的情况下构建并运行良好。
我的顶级Android.mk包括2个显式的SQLite.mk和Hello.mk行。
我已经在所有这些.mk文件中指定了完整路径,仅仅是为了我自己的理智。
SQLite.mk如下:

LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)JNILIB_PATH := C:/androidprojects/SDLTest_SQLite/app/jniLibs SRC_SQLITE := C:/androidprojects/SDLTest_SQLite/app/jni/SQLite/sqlite3.cLOCAL_CFLAGS += -Wno-write-stringsLOCAL_MODULE:= SQLite LOCAL_SRC_FILES := $(SRC_SQLITE)TARGET_OUT=$(JNILIB_PATH)/$(TARGET_ARCH_ABI) #TARGET_OUT=../jniLibs/$(TARGET_ARCH_ABI)include $(BUILD_STATIC_LIBRARY)

Android Studio / Gradle错误如下:
Android NDK: ERROR:C:androidprojectsSDLTest_SQLiteappjniAndroid.mk:SQLite: LOCAL_SRC_FILES points to a missing file Android NDK: Check that C:/androidprojects/SDLTest_SQLite/app/jniLibs/armeabi/libSQLite.a existsor that its path is correct Build command failed.

我的根本问题是我无法在任何地方生成libSQLite.a文件。我的TARGET_OUT排队问题了吗?
有人可以帮我生成我的静态库文件吗?
Here is a link to my project
答案你不应该在Android.mk中设置TARGET_OUT:这是打破微妙的ndk构建逻辑的可靠方法。你的两个mk文件互不矛盾:SQLite既不能预先构建,也不能从源代码构建。
我不知道为什么你的错误消息说缺少SQLite源,但是你使用了不健康的完整路径。
以下是三个完成工作的mk文件:
Android.门口
ROOT_PATH:= $(call my-dir)include $(ROOT_PATH)/src/Hello.mk include $(ROOT_PATH)/SQLite/SQLite.mk

SQLite.门口
LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)SRC_SQLITE := sqlite3.cLOCAL_CFLAGS += -Wno-write-stringsLOCAL_MODULE:= SQLite LOCAL_SRC_FILES := $(SRC_SQLITE)include $(BUILD_STATIC_LIBRARY)

hello.门口
LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS) LOCAL_MODULE := libSDL2 LOCAL_SRC_FILES := ../../jniLibs/SDL2-prebuilt/$(TARGET_ARCH_ABI)/libSDL2.so include $(PREBUILT_SHARED_LIBRARY)include $(CLEAR_VARS)LOCAL_MODULE := mainSDL_PATH := $(LOCAL_PATH)/../../jniLibs/SDL2-prebuiltLOCAL_C_INCLUDES := $(SDL_PATH)/include# Add your application source files here... LOCAL_SRC_FILES := 52_hello_mobile.cpp LOCAL_STATIC_LIBRARIES := libSDL2 SQLite LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -lloginclude $(BUILD_SHARED_LIBRARY)

后者可以稍微改善一下:
LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS) LOCAL_MODULE := libSDL2 LOCAL_SRC_FILES := ../../jniLibs/SDL2-prebuilt/$(TARGET_ARCH_ABI)/libSDL2.so SDL_PATH := $(LOCAL_PATH)/../../jniLibs/SDL2-prebuilt LOCAL_EXPORT_C_INCLUDES := $(SDL_PATH)/includeinclude $(PREBUILT_SHARED_LIBRARY)include $(CLEAR_VARS)LOCAL_MODULE := main# Add your application source files here... LOCAL_SRC_FILES := 52_hello_mobile.cpp LOCAL_STATIC_LIBRARIES := libSDL2 SQLite LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -lloginclude $(BUILD_SHARED_LIBRARY)

还有一个狐狸你的设置:你不能用APP_PLATFORM=14构建64位版本。您应该使用至少21的compileSdkVersion,并且不要显式设置APP_PLATFORM。然后,gradle将根据minSdkVersion为32位目标(即APP_PLATFORM)自动设置android-14,并将其推送到android-21以获得64位目标。
在Application.mk中,qazxsw poi设置被默默忽略。

    推荐阅读