Reputation: 61
My app has several JNI modules. I use Android.mk to define modules and what files to be built for each module. So I had to disable automatic ndk-build call. My gradle contains the following:
sourceSets.main {
jni.srcDirs = [] //disable automatic ndk-build call with auto-generated Android.mk file
jniLibs.srcDirs = ['src/main/libs']
}
task buildNative(type: Exec, description: 'Compile JNI source via NDK') {
commandLine "ndk-build.cmd",
'-C', file('src/main/jni').absolutePath,
'-j', Runtime.runtime.availableProcessors(),
'all'
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn buildNative
}
Since now Android Studio support NDK and native debugging, I'd need to use new experimental gradle plugin. There's a section that I need to specify the module name.
android.ndk {
// All configurations that can be changed in android.ndk.
moduleName = "native"
toolchain = "clang"
toolchainVersion = "3.5"
// Note that CFlags has a capital C, which is inconsistent with
// the naming convention of other properties. This is a
// technical limitation that will be resolved
CFlags += "-DCUSTOM_DEFINE"
cppFlags += "-DCUSTOM_DEFINE"
ldFlags += "-L/custom/lib/path"
ldLibs += "log"
stl = "stlport_static"
}
However, all examples I see only specify one module and there's no way to specify which file to be built against that module.
Does anybody have any idea how to define several modules and specify files for each module in this new experimental gradle plugin?
Upvotes: 6
Views: 1990
Reputation: 10504
The new experimental gradle doesn't yet support building standalone native library module.
This is a known limitation being tracker on b.android.com/177631.
Upvotes: 0