When using Eclipse,we can build binary executables by edited Android.mk as follow:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := Test
LOCAL_SRC_FILES := Test.cpp
include $(BUILD_EXECUTABLE) // here is the KEY!
At the end, how to Build C/C++ Executables for android using ANDROID STUDIO? Thanks.
For now Android Studio doesn't officially support NDK, but you can add a gradle task to take care of building your C/C++ stuff; something like that :
task buildNativeLibs(type: Exec){
workingDir './my_dir'
commandLine 'cmd', '/c', 'ndk-build'
}
preBuild.dependsOn(buildNativeLibs)
Note that this is for Windows, for Unix systems the commandLine will be more like
commandLine './ndk-build.sh'
Be careful that sometimes gradle is very with annoying environment vars (doesn't always find exe that are exposed through PATH), so if you have issues try pasting the ndk-build executable in the workingDir
Hope this helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.