今天用jni编译so库一直报错
D:\AS\AndroidSdk\ndk\19.2.5345600\ndk-build.cmd
Android NDK: WARNING: APP_PLATFORM android-19 is higher than android:minSdkVersion 1 in ./AndroidManifest.xml. NDK binaries will *not* be compatible with devices older than android-19. See https://android.googlesource.com/platform/ndk/+/master/docs/user/common_problems.md for more information.
D:/AS/AndroidSdk/ndk/19.2.5345600/build//../build/core/build-static-library.mk:26: *** Android NDK: Aborting . Stop.
Android NDK: jni/Android.mk:FreeTypeLibs: LOCAL_MODULE_FILENAME must not contain a file extension
Process finished with exit code 2
查了下发现Android.mk写的两行不同同时存在
include $(BUILD_SHARED_LIBRARY)//编译动态.so库
include $(BUILD_STATIC_LIBRARY)//编译静态.a库
解决办法去掉其中一句,即需要编译动态库还是静态库,一个一个来就行
最后
Android.mk编译动态库.so库
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := FreeTypeLibs
LOCAL_SRC_FILES =: aMyTest.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../jni
LOCAL_LDLIBS += -lm -llog
include $(BUILD_SHARED_LIBRARY)
Android.mk编译动态库.a库
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := FreeTypeLibs
LOCAL_SRC_FILES =: aMyTest.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../jni
LOCAL_LDLIBS += -lm -llog
include $(BUILD_STATIC_LIBRARY)
具体的jni编译步骤可查看之前的文章:https://www.jianshu.com/p/4485be6402d5
网友评论