How to specify external C++ source folders for Android NDK with Gradle -
i want add c++ source files android studio project not in project tree. i'm new gradle, , tried research as possible. read, following build.gradle file should work, doesn't. bit jni.sourcedirs
came post: http://www.shaneenishry.com/blog/2014/08/17/ndk-with-android-studio/
is right approach?
apply plugin: 'com.android.application' android { compilesdkversion 22 buildtoolsversion "22.0.1" defaultconfig { applicationid "com.mycompany.myapp" minsdkversion 22 targetsdkversion 22 ndk { modulename "mymodule" ldlibs "log" } } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.txt' } } sourcesets.main { jni.srcdirs '../external/source/dir' } }
have @ article this: http://www.sureshjoshi.com/mobile/android-ndk-in-android-studio-with-swig/
there 2 things need know here. default, if have external libs want loaded android application, looked in (module)/src/main/jnilibs. can change using setting sourcesets.main.jnilibs.srcdirs in module’s build.gradle. you’ll need subdirectory libraries each architecture you’re targeting (e.g. x86, arm, mips, arm64-v8a, etc…)
the code want compiled default ndk toolchain located in (module)/src/main/jni , above, can change setting sourcesets.main.jni.srcdirs in module’s build.gradle
and sample gradle file page:
apply plugin: 'com.android.application' android { compilesdkversion 21 buildtoolsversion "21.1.2" defaultconfig { applicationid "com.sureshjoshi.android.ndkexample" minsdkversion 15 targetsdkversion 21 versioncode 1 versionname "1.0" ndk { modulename "seeplusplus" // name of c++ module (i.e. libseeplusplus) cflags "-std=c++11 -fexceptions" // add provisions allow c++11 functionality stl "gnustl_shared" // stl library use: gnustl or stlport } } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } }
also, when specifying external /jni directory, try using full build path (using 1 of macros, eg):
'${project.builddir}/../../thirdparty/blah/blah/'
Comments
Post a Comment