我已经成功构建了使用本机(JNI)库的Android应用(GUI)。
但是,现在我想创建一个从命令行运行的可执行文件(root特权),并且根本不使用GUI。我该如何构建类似的东西?
从NDK r8d开始,这可以通过更简单的方式解决。
project/ jni/ Android.mk Application.mk *.c, *.cpp, *.h, etc.
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := name-of-your-executable LOCAL_SRC_FILES := a.cpp b.cpp c.cpp etc.cpp LOCAL_CPPFLAGS := -std=gnu++0x -Wall -fPIE # whatever g++ flags you like LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog -fPIE -pie # whatever ld flags you like include $(BUILD_EXECUTABLE) # <-- Use this to build an executable.
project/
ndk-build
结果将放置在中project/libs/<arch>/name-of-your-executable。
project/libs/<arch>/name-of-your-executable