How do I enable ARM NEON builds using Gradle?
<p>Since Gradle seems to be the new-hotness being pushed by Google over Android.mk, how does one enable NEON for ARM builds?  I'm explicitly not interested in solutions that invoke a legacy Android.mk file, as I want to get ARM NEON builds working using just the new Gradle system and not a hybrid approach.</p>

<p>Here's a hacked up test build.gradle from the hello-jni project in the NDK:</p>

<pre><code>apply plugin: 'com.android.model.application'

model {
    android {
        compileSdkVersion = 23
        buildToolsVersion = "23.0.2"

        defaultConfig.with {
            applicationId = "com.example.hellojni"
            minSdkVersion.apiLevel = 4
            targetSdkVersion.apiLevel = 23
        }
    }

    compileOptions.with {
        sourceCompatibility=JavaVersion.VERSION_1_7
        targetCompatibility=JavaVersion.VERSION_1_7
    }

    /*
     * native build settings
     */
    android.ndk {
        moduleName = "hello-jni"
        /*
         * Other ndk flags configurable here are
         * cppFlags.add("-fno-rtti")
         * cppFlags.add("-fno-exceptions")
         * ldLibs.addAll(["android", "log"])
         * stl       = "system"
         */
        cppFlags.add("-std=c++11")
        cppFlags.add("-fexceptions")
        cppFlags.add("-DNOPENCL")
        stl = "c++_static"
    }
    android.buildTypes {
        release {
            minifyEnabled = false
            proguardFiles.add(file('proguard-rules.txt'))
        }
    }
    android.productFlavors {
        // for detailed abiFilter descriptions, refer to "Supported ABIs" @
        // https://developer.android.com/ndk/guides/abis.html#sa
        create("arm7") {
            ndk.abiFilters.add("armeabi-v7a")
        }
        create("x86") {
            ndk.abiFilters.add("x86")
        }
        create("x86-64") {
            ndk.abiFilters.add("x86_64")
        }
    }
}
</code></pre>

<p>However <code>__ARM_NEON__</code> isn't being defined according to the following code:</p>

<pre><code>#if defined(__arm__)
#if defined(__ARM_ARCH_7A__)
  #if defined(__ARM_NEON__)
    #if defined(__ARM_PCS_VFP)
      #define ABI "armeabi-v7a/NEON (hard-float)"
    #else
      #define ABI "armeabi-v7a/NEON"
    #endif
  #else
    #if defined(__ARM_PCS_VFP)
      #define ABI "armeabi-v7a (hard-float)"
    #else
      #define ABI "armeabi-v7a"
    #endif
  #endif
#else
 #define ABI "armeabi"
#endif
#elif defined(__i386__)
#define ABI "x86"
#elif defined(__x86_64__)
#define ABI "x86_64"
#elif defined(__mips64)  /* mips64el-* toolchain defines __mips__ too */
#define ABI "mips64"
#elif defined(__mips__)
#define ABI "mips"
#elif defined(__aarch64__)
#define ABI "arm64-v8a"
#else
#define ABI "unknown"
#endif
</code></pre>

<p>Any thoughts?  I've also tried setting <code>abiFilters</code> to <code>armeabi-v7a-hard</code> with no luck and also explicitly passing <code>-mfloat-abi=hard</code> and <code>-mfpu-neon</code> as <code>cppFlags</code> (but this obviously breaks builds for other platforms).</p>