下载NDK22
https://developer.android.com/ndk/downloads?hl=zh-cn
解压到/mnt/data/bin/ndk22
运行一下看看解压路径是否正确:
root@CTS:/mnt/data/bin/ndk22# ./ndk-build
Android NDK: Could not find application project directory !
Android NDK: Please define the NDK_PROJECT_PATH variable to point to it.
/mnt/data/bin/ndk22/build/core/build-local.mk:151: *** Android NDK: Aborting . Stop.
创建jni目录,
cd /mnt/data/bin/ndk22
mkdir jni
/mnt/data/bin/ndk22/jin目录下创建main.cpp
#include<stdio.h>
int main()
{
printf("hello\n");
return 0;
}
/mnt/data/bin/ndk22/jni目录下创建Android.mk
APP_PLATFORM := android-16
APP_ALLOW_MISSING_DEPS=true
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := main
LOCAL_SRC_FILES := main.cpp
编译:
/mnt/data/bin/ndk22/ndk-build
推送到手机:(32位ARM版本)
cd /mnt/data/bin/ndk22/libs/armeabi-v7a
adb push main /data/sdcard/
执行:
adb shell /data/sdcard/main