In order to get indexing in the Android Studio editor I should add the following code in build.gradle:
ndk {
moduleName "MyModule"
CFlags.add("-I${file("src/main/jni/headers1")}".toString())
CFlags.add("-I${file("src/main/jni/headers2")}".toString())
}
but then gradle ignores my Android.mk, If I will remove this code from build.gradle, then I won't get proper indexing in the editor since all the header files are in those 2 folders. Is anyone knows how to make gradle to compile by my Android.mk and and still get native editing and debugging?
Im using: Android Studio 2.1 stable gradle-experimental:0.7.0 my build.grade:
apply plugin: "com.android.model.application"
def ndkDir = System.getenv("ANDROID_NDK_HOME")
def propertiesFile = project.rootProject.file('local.properties')
if (propertiesFile.exists()) {
Properties properties = new Properties()
properties.load(propertiesFile.newDataInputStream())
ndkDir = properties.getProperty('ndk.dir')
}
model {
android.sources {
main {
jni {
source {
srcDirs.removeAll()
srcDir 'src/main/none'
}
}
jniLibs {
source {
srcDir 'src/main/libs'
}
}
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
ndk {
moduleName "MyModule"
CFlags.add("-I${file("src/main/jni/headers1")}".toString())
CFlags.add("-I${file("src/main/jni/headers2")}".toString())
}
defaultConfig {
applicationId "com.myapp.android.me"
minSdkVersion.apiLevel 19
targetSdkVersion.apiLevel 23
}
buildTypes {
debug {
ndk {
debuggable = true
}
}
}
}
}
dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
compile 'com.google.code.gson:gson:2.2.4'
}
task buildNative(type: Exec, description: 'Compile JNI source via NDK'){
commandLine "${ndkDir}/ndk-build",'NDK_DEBUG=1','NDK_PROJECT_PATH ='+ getProjectDir() + '/src/main'
}
tasks.withType(AbstractCompile) {
compileTask -> compileTask.dependsOn buildNative
}