How can I add a static library to Android NDK using the build.gradle file? -
i'm trying learn use ndk in androidstudio, , i'd import "android_native_app_glue" file used in "native-activity" sample, have framework basic functions display, touch, etc. in sample, loads library line in android.mk file:
local_static_libraries := android_native_app_glue
and imports in "main.c" with:
#include <android_native_app_glue.h>
but in androidstudio, far can tell experimenting it, doesn't use android.mk file @ , instead uses build.gradle file same functions instead. so, example, replace local_ldlibs := ...
in android.mk, used ldlibs = ...
in build.gradle. gradle code replaces local_static_libraries
?
is there resource somewhere explains, in general, how translate android.mk build.gradle?
if want make work without makefiles, can copy , paste ndk\sources\android\native_app_glue\android_native_app_glue.(c|h)
jni folder , add android
ldlibs.
else, can still rely on classic makefiles, deactivating default call ndk-build, , making gradle use libs libs
directory:
sourcesets.main { jnilibs.srcdir 'src/main/libs' jni.srcdirs = [] //disable automatic ndk-build call }
in case you'll have call ndk-build
yourself, can make gradle call you:
// call regular ndk-build(.cmd) script app directory task ndkbuild(type: exec) { if (os.isfamily(os.family_windows)) { commandline 'ndk-build.cmd', '-c', file('src/main').absolutepath } else { commandline 'ndk-build', '-c', file('src/main').absolutepath } } tasks.withtype(javacompile) { compiletask -> compiletask.dependson ndkbuild }
Comments
Post a Comment