title: Android Studio: New gradle build NDK sample app error
body: <p>I build sample project MoreTeapots from <a href="https://github.com/googlesamples/android-ndk" rel="nofollow">https://github.com/googlesamples/android-ndk</a> and get errors </p>
  
  <blockquote>
    <p>Information:Gradle tasks [:app:assembleAllDebug]
    :app:copyArm64-v8aDebugAllMoreTeapotsNativeActivitySharedLibraryGdbServer
    :app:createArm64-v8aDebugAllMoreTeapotsNativeActivitySharedLibraryGdbsetup
    :app:compileArm64-v8aDebugAllMoreTeapotsNativeActivitySharedLibraryMoreTeapotsNativeActivityMainC
    :app:compileArm64-v8aDebugAllMoreTeapotsNativeActivitySharedLibraryMoreTeapotsNativeActivityMainCpp
    :app:linkArm64-v8aDebugAllMoreTeapotsNativeActivitySharedLibrary
    :app:stripSymbolsArm64-v8aDebugAllMoreTeapotsNativeActivitySharedLibrary
    :app:arm64-v8aDebugAllMoreTeapotsNativeActivitySharedLibrary
    :app:copyArmeabi-v7aDebugAllMoreTeapotsNativeActivitySharedLibraryGdbServer
    :app:createArmeabi-v7aDebugAllMoreTeapotsNativeActivitySharedLibraryGdbsetup
    :app:compileArmeabi-v7aDebugAllMoreTeapotsNativeActivitySharedLibraryMoreTeapotsNativeActivityMainC
    :app:compileArmeabi-v7aDebugAllMoreTeapotsNativeActivitySharedLibraryMoreTeapotsNativeActivityMainCpp
    :app:linkArmeabi-v7aDebugAllMoreTeapotsNativeActivitySharedLibrary
    :app:stripSymbolsArmeabi-v7aDebugAllMoreTeapotsNativeActivitySharedLibrary
    :app:armeabi-v7aDebugAllMoreTeapotsNativeActivitySharedLibrary
    :app:copyArmeabiDebugAllMoreTeapotsNativeActivitySharedLibraryGdbServer
    :app:createArmeabiDebugAllMoreTeapotsNativeActivitySharedLibraryGdbsetup
    :app:compileArmeabiDebugAllMoreTeapotsNativeActivitySharedLibraryMoreTeapotsNativeActivityMainC
    :app:compileArmeabiDebugAllMoreTeapotsNativeActivitySharedLibraryMoreTeapotsNativeActivityMainCpp
    :app:linkArmeabiDebugAllMoreTeapotsNativeActivitySharedLibrary
    :app:stripSymbolsArmeabiDebugAllMoreTeapotsNativeActivitySharedLibrary
    :app:armeabiDebugAllMoreTeapotsNativeActivitySharedLibrary
    :app:preBuild UP-TO-DATE
    :app:preAllDebugBuild UP-TO-DATE
    :app:checkAllDebugManifest
    :app:prepareAllDebugDependencies
    :app:compileAllDebugAidl UP-TO-DATE
    :app:compileAllDebugRenderscript UP-TO-DATE
    :app:generateAllDebugBuildConfig UP-TO-DATE
    :app:generateAllDebugAssets UP-TO-DATE
    :app:mergeAllDebugAssets UP-TO-DATE
    :app:generateAllDebugResValues UP-TO-DATE
    :app:generateAllDebugResources UP-TO-DATE
    :app:mergeAllDebugResources UP-TO-DATE
    :app:processAllDebugManifest UP-TO-DATE
    :app:processAllDebugResources UP-TO-DATE
    :app:generateAllDebugSources UP-TO-DATE
    :app:processAllDebugJavaRes UP-TO-DATE
    :app:compileAllDebugJavaWithJavac
    Note: C:\Users\Cuong\Downloads\MoreTeapots\app\src\main\java\com\sample\moreteapots\MoreTeapotsNativeActivity.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    :app:copyMips64DebugAllMoreTeapotsNativeActivitySharedLibraryGdbServer
    :app:createMips64DebugAllMoreTeapotsNativeActivitySharedLibraryGdbsetup
    :app:compileMips64DebugAllMoreTeapotsNativeActivitySharedLibraryMoreTeapotsNativeActivityMainC
    :app:compileMips64DebugAllMoreTeapotsNativeActivitySharedLibraryMoreTeapotsNativeActivityMainCpp
    :app:linkMips64DebugAllMoreTeapotsNativeActivitySharedLibrary
    :app:stripSymbolsMips64DebugAllMoreTeapotsNativeActivitySharedLibrary
    :app:mips64DebugAllMoreTeapotsNativeActivitySharedLibrary
    :app:copyMipsDebugAllMoreTeapotsNativeActivitySharedLibraryGdbServer
    :app:createMipsDebugAllMoreTeapotsNativeActivitySharedLibraryGdbsetup
    :app:compileMipsDebugAllMoreTeapotsNativeActivitySharedLibraryMoreTeapotsNativeActivityMainC
    :app:compileMipsDebugAllMoreTeapotsNativeActivitySharedLibraryMoreTeapotsNativeActivityMainCpp
    :app:linkMipsDebugAllMoreTeapotsNativeActivitySharedLibrary
    :app:stripSymbolsMipsDebugAllMoreTeapotsNativeActivitySharedLibrary
    :app:mipsDebugAllMoreTeapotsNativeActivitySharedLibrary
    :app:copyX86DebugAllMoreTeapotsNativeActivitySharedLibraryGdbServer
    :app:createX86DebugAllMoreTeapotsNativeActivitySharedLibraryGdbsetup
    :app:compileX86DebugAllMoreTeapotsNativeActivitySharedLibraryMoreTeapotsNativeActivityMainC
    :app:compileX86DebugAllMoreTeapotsNativeActivitySharedLibraryMoreTeapotsNativeActivityMainCpp
    :app:linkX86DebugAllMoreTeapotsNativeActivitySharedLibrary
    :app:stripSymbolsX86DebugAllMoreTeapotsNativeActivitySharedLibrary
    :app:x86DebugAllMoreTeapotsNativeActivitySharedLibrary
    :app:copyX86_64DebugAllMoreTeapotsNativeActivitySharedLibraryGdbServer
    :app:createX86_64DebugAllMoreTeapotsNativeActivitySharedLibraryGdbsetup
    :app:compileX86_64DebugAllMoreTeapotsNativeActivitySharedLibraryMoreTeapotsNativeActivityMainC
    :app:compileX86_64DebugAllMoreTeapotsNativeActivitySharedLibraryMoreTeapotsNativeActivityMainCpp
    :app:linkX86_64DebugAllMoreTeapotsNativeActivitySharedLibrary
    :app:stripSymbolsX86_64DebugAllMoreTeapotsNativeActivitySharedLibrary
    :app:x86_64DebugAllMoreTeapotsNativeActivitySharedLibrary
    :app:compileAllDebugSources
    :app:preDexAllDebug
    :app:dexAllDebug
    UNEXPECTED TOP-LEVEL EXCEPTION:
    ...while parsing com/sample/helper/NDKHelper.class
    UNEXPECTED TOP-LEVEL EXCEPTION:
    ...while parsing com/sample/moreteapots/BuildConfig.class
    UNEXPECTED TOP-LEVEL EXCEPTION:
    ...while parsing com/sample/moreteapots/MoreTeapotsApplication.class
    UNEXPECTED TOP-LEVEL EXCEPTION:
    ...while parsing com/sample/moreteapots/MoreTeapotsNativeActivity$1.class
    UNEXPECTED TOP-LEVEL EXCEPTION:
    ...while parsing com/sample/moreteapots/MoreTeapotsNativeActivity$2.class
    UNEXPECTED TOP-LEVEL EXCEPTION:
    ...while parsing com/sample/moreteapots/MoreTeapotsNativeActivity$3.class
    UNEXPECTED TOP-LEVEL EXCEPTION:
    ...while parsing com/sample/moreteapots/MoreTeapotsNativeActivity.class
    UNEXPECTED TOP-LEVEL EXCEPTION:
    ...while parsing com/sample/moreteapots/R$attr.class
    UNEXPECTED TOP-LEVEL EXCEPTION:
    ...while parsing com/sample/moreteapots/R$drawable.class
    UNEXPECTED TOP-LEVEL EXCEPTION:
    ...while parsing com/sample/moreteapots/R$id.class
    UNEXPECTED TOP-LEVEL EXCEPTION:
    ...while parsing com/sample/moreteapots/R$layout.class
    UNEXPECTED TOP-LEVEL EXCEPTION:
    ...while parsing com/sample/moreteapots/R$string.class
    UNEXPECTED TOP-LEVEL EXCEPTION:
    ...while parsing com/sample/moreteapots/R$style.class
    UNEXPECTED TOP-LEVEL EXCEPTION:
    ...while parsing com/sample/moreteapots/R.class
    14 errors; aborting
    Error:Execution failed for task ':app:dexAllDebug'.
    com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_45\bin\java.exe'' finished with non-zero exit value 1
    Information:BUILD FAILED
    Information:Total time: 4 mins 1.033 secs
    Information:1 error
    Information:0 warnings
    Information:See complete output in console</p>
  </blockquote>
  
  <p>This is guide <a href="http://tools.android.com/tech-docs/new-build-system/gradle-experimental" rel="nofollow">http://tools.android.com/tech-docs/new-build-system/gradle-experimental</a>.
  Its app build.gradle</p>
  
  <pre><code>apply plugin: 'com.android.model.application'
  
  model {
  android {
      compileSdkVersion    = 22
      buildToolsVersion    ="22.0.1"
  
      defaultConfig.with {
          applicationId    = "com.sample.moreteapots"
          minSdkVersion.apiLevel    = 11
          targetSdkVersion.apiLevel = 22
  
      }
  }
  android.ndk {
      moduleName ="MoreTeapotsNativeActivity"
      cppFlags   += "-I${file("src/main/jni/cpufeatures")}".toString()
      cppFlags   += "-I${file("src/main/jni/native_app_glue")}".toString()
      cppFlags   += "-I${file("src/main/jni/ndk_helper")}".toString()
  
      // CFlags is configured in similiar way as cppFlags
      // CFlags    += "-I${file("src/main/jni/native_app_glue")}".toString()
  
      ldLibs     += ["android", "EGL", "GLESv2","log"]
      stl         = "stlport_static"
  }
  
  android.sources {
      main {
          jni {
              source {
                  srcDirs 'src/main/jni'
              }
          }
      }
  }
  
  android.productFlavors {
      create ("arm7") {
          ndk.abiFilters += "armeabi-v7a"
      }
      create ("arm8") {
          ndk.abiFilters += "arm64-v8a"
      }
      create ("x86-32") {
          ndk.abiFilters += "x86"
      }
      // for detailed abiFilter descriptions, refer to "Supported ABIs" @
      // https://developer.android.com/ndk/guides/abis.html#sa
      // build one including all productFlavors
      create("all")
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Its project build.gradle</p>
  
  <pre><code>// Top-level build file where you can add configuration options common to      all sub-projects/modules.
  buildscript {
  repositories {
     maven {
       url  "http://dl.bintray.com/android/android-tools"
     }
     jcenter()
  }
  dependencies {
      classpath 'com.android.tools.build:gradle-experimental:0.1.0'
  }
  }
  
  allprojects {
  repositories {
      jcenter()
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Its gradle-wrapper.properties</p>
  
  <pre><code>#Wed Apr 10 15:27:10 PDT 2013
  distributionBase=GRADLE_USER_HOME
  distributionPath=wrapper/dists
  zipStoreBase=GRADLE_USER_HOME
  zipStorePath=wrapper/dists
  distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-rc-1-bin.zip
  </code></pre>
  
  <p>How can I solve? Thanks.</p>
  
  <p>UPDATE: Solved.  I add </p>
  
  <pre><code>    compileOptions.with {
      sourceCompatibility = JavaVersion.VERSION_1_7
      targetCompatibility = JavaVersion.VERSION_1_7
  }
  </code></pre>
  
  <p>to app build.gradle like</p>
  
  <pre><code>apply plugin: 'com.android.model.application'
  model {
  android {
      compileSdkVersion    = 22
      buildToolsVersion    ="22.0.1"
  
      defaultConfig.with {
          applicationId    = "com.sample.moreteapots"
          minSdkVersion.apiLevel    = 10
          targetSdkVersion.apiLevel = 22
  
      }
  }
  android.ndk {
      moduleName ="MoreTeapotsNativeActivity"
      cppFlags   += "-I${file("src/main/jni/cpufeatures")}".toString()
      cppFlags   += "-I${file("src/main/jni/native_app_glue")}".toString()
      cppFlags   += "-I${file("src/main/jni/ndk_helper")}".toString()
  
      // CFlags is configured in similiar way as cppFlags
      // CFlags    += "-I${file("src/main/jni/native_app_glue")}".toString()
  
      ldLibs     += ["android", "EGL", "GLESv2","log"]
      stl         = "stlport_static"
  }
  
  android.sources {
      main {
          jni {
              source {
                  srcDirs 'src/main/jni'
              }
          }
      }
  }
  
  android.productFlavors {
      create ("arm7") {
          ndk.abiFilters += "armeabi-v7a"
      }
      create ("arm8") {
          ndk.abiFilters += "arm64-v8a"
      }
      create ("x86-32") {
          ndk.abiFilters += "x86"
      }
      // for detailed abiFilter descriptions, refer to "Supported ABIs" @
      // https://developer.android.com/ndk/guides/abis.html#sa
      // build one including all productFlavors
      create("all")
  }
  compileOptions.with {
      sourceCompatibility = JavaVersion.VERSION_1_7
      targetCompatibility = JavaVersion.VERSION_1_7
  }
  </code></pre>
  
  <p>}</p>