title: Android NDK and Gradle: Different Android.mk per build type
body: <p>My native library contains logs which I would like to remove at compile time.
  Logs are shown by defining the pre-processor macro <code>ENABLE_DEBUG</code> in <code>LOCAL_CFLAGS</code> like so:</p>
  
  <pre><code>include $(CLEAR_VARS)
  LOCAL_MODULE    := native-stuff
  LOCAL_SRC_FILES := Native.cpp
  LOCAL_LDLIBS := -llog
  LOCAL_CFLAGS := -DENABLE_DEBUG
  include $(BUILD_SHARED_LIBRARY)
  </code></pre>
  
  <p>I'm building the app with Gradle via Android Studio and I would like to have another Android.mk file without <code>LOCAL_CFLAGS := -DENABLE_DEBUG</code> for release builds, effectively disabling logging.</p>
  
  <p>I tried to do it by creating the folders <code>release/jni</code> under <code>src</code> and put a copy of Android.mk without the CFLAGS. It builds and deploys successfully, but I still see the logs. Here is my <code>build.gradle</code>:</p>
  
  <pre><code>apply plugin: 'com.android.library'
  
  android {
      compileSdkVersion 21
      buildToolsVersion "21.1.2"
  
      defaultConfig {
          minSdkVersion 17
          targetSdkVersion 21
          versionCode 1
          versionName "1.0"
      }
  
      sourceSets {
          main {
              //Tell Gradle where to put the compiled shared library
              jniLibs.srcDir 'src/main/libs'
  
              //disable automatic ndk-build call
              jni.srcDirs = [];
          }
          release {
              jni.srcDirs = [];
          }
      }
  
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  
      // Tell Gradle the run the ndkBuild task when compiling
      tasks.withType(JavaCompile) {
          compileTask -&gt; compileTask.dependsOn ndkBuild
      }
  
      // This task utilizes the Android.mk file defined in src/main/jni so that you
      // have more control over the build parameters (like library inclusion)
      // The system must define property 'androidNdkHome' in ~/.gradle/gradle.properties file
      // to point to NDK path
      task ndkBuild(type: Exec) {
          commandLine "$androidNdkHome/ndk-build", '-C', file('src/main/jni').absolutePath
      }
  }
  
  dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      compile 'com.android.support:support-v4:21.0.2'
  }
  </code></pre>
  
  <p>My project structure looks like this:</p>
  
  <pre><code>src/
     main/
         jni/
            Android.mk
     release/
         jni/
            Android.mk
  </code></pre>
  
  <p>Is it possible to do what I want?</p>