我的应用程序有几个JNI模块。我使用Android.mk来定义模块以及为每个模块构建的文件。所以我不得不禁用自动ndk-build调用。我的gradle包含以下内容:
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
}
由于现在Android Studio支持NDK和本机调试,我需要使用新的实验性gradle插件。我需要指定模块名称的部分。
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"
}
但是,我看到的所有示例都只指定了一个模块,并且无法指定针对该模块构建的文件。
有没有人知道如何在这个新的实验性gradle插件中定义几个模块并为每个模块指定文件?