Android Studio NDK使用总结
1.安装配置ndk
打开 File>Project Structure
可以配置ndk路径,如果ndk没有下载那么在标记的地方会有一个ndk下载链接
2.配置ndk工具
打卡 Preference>Tools>External Tools
3.添加工具配置
点击上方截图的+号即可添加,显示添加页面
标记1:选中ndk的路径,需要选到ndk-build
标记2:选中需要打包的.h文件所在的目录
4.生成so文件,直接执行ndk build就生成了
配置文件:Android.mk
TOP_LOCAL_PATH := $(call my-dir)
include $(call all-subdir-makefiles)
LOCAL_PATH := $(TOP_LOCAL_PATH)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/ $(LOCAL_PATH)/lib/include
LOCAL_SRC_FILES := ZstClientLib.c
LOCAL_SHARED_LIBRARIES := VidyoClientApp
LOCAL_LDLIBS = -llog
LOCAL_MODULE := ZstClientLib
include $(BUILD_SHARED_LIBRARY)
配置文件:Application.mk
APP_PLATFORM:= android-14
APP_PROJECT_PATH := $(call my-dir)/..
APP_BUILD_SCRIPT := $(APP_PROJECT_PATH)/jni/Android.mk
#APP_OPTIM := debug
APP_OPTIM := release
APP_ABI := armeabi-v7a
APP_STL := gnustl_static
Android.mk文件详细解释
https://blog.csdn.net/love_heller/article/details/51556434
遇到的问题:
android studio ndk Process finished with exit code 2
提示 *.o.d文件报错,
解决方法:检查发现原项目是在Windows环境中运行的,所以这里保存的路径信息都是windows格式的,只需要把信息清除,重新生成就行了