title: Android Studio 3.1.2 gradle build error
body: <p>I'm trying to get a project to build but keep getting build errors. I've basically tried all I can from different question here on SO and google but no success yet. I've tried:</p>
  
  <ul>
  <li>Invalidating cache and restarting</li>
  <li>Syncing project with file system</li>
  <li>Syncing project with gradle files</li>
  <li>Downloaded sdk tools (all just in case)</li>
  <li>Downloaded the latest gradle and pointed android studio gradle home to it
  But still I keep running into this
  <a href="https://i.stack.imgur.com/49wcx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/49wcx.png" alt="Build error screenshot"></a></li>
  </ul>
  
  <p>Which points me to this import line on build.gradle</p>
  
  <p><a href="https://i.stack.imgur.com/vT3j6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vT3j6.png" alt="build.gradle error line screenshot"></a></p>
  
  <p>What could I be missing and what's causing the gradle build error seeing that I have downloaded and installed what there is to download and install?</p>
  
  <p>This is the build error stack trace.</p>
  
  <pre><code>org.gradle.api.GradleScriptException: A problem occurred evaluating project ':app'.
      at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:92)
      at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$2.run(DefaultScriptPluginFactory.java:204)
      at org.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:77)
      at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:209)
      at org.gradle.configuration.BuildOperationScriptPlugin$1.run(BuildOperationScriptPlugin.java:61)
      at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
      at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
      at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
      at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:97)
      at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
      at org.gradle.configuration.BuildOperationScriptPlugin.apply(BuildOperationScriptPlugin.java:58)
      at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:41)
      at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
      at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
      at org.gradle.configuration.project.LifecycleProjectEvaluator.doConfigure(LifecycleProjectEvaluator.java:64)
      at org.gradle.configuration.project.LifecycleProjectEvaluator.access$100(LifecycleProjectEvaluator.java:34)
      at org.gradle.configuration.project.LifecycleProjectEvaluator$ConfigureProject.run(LifecycleProjectEvaluator.java:110)
      at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
      at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
      at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
      at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:97)
      at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
      at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:50)
      at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:667)
      at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:136)
      at org.gradle.execution.TaskPathProjectEvaluator.configure(TaskPathProjectEvaluator.java:35)
      at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:62)
      at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:38)
      at org.gradle.initialization.DefaultGradleLauncher$ConfigureBuild.run(DefaultGradleLauncher.java:261)
      at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
      at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
      at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
      at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:97)
      at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
      at org.gradle.initialization.DefaultGradleLauncher.configureBuild(DefaultGradleLauncher.java:173)
      at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:132)
      at org.gradle.initialization.DefaultGradleLauncher.getConfiguredBuild(DefaultGradleLauncher.java:110)
      at org.gradle.internal.invocation.GradleBuildController$2.call(GradleBuildController.java:87)
      at org.gradle.internal.invocation.GradleBuildController$2.call(GradleBuildController.java:84)
      at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:152)
      at org.gradle.internal.work.StopShieldingWorkerLeaseService.withLocks(StopShieldingWorkerLeaseService.java:38)
      at org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:100)
      at org.gradle.internal.invocation.GradleBuildController.configure(GradleBuildController.java:84)
      at org.gradle.tooling.internal.provider.runner.ClientProvidedBuildActionRunner.run(ClientProvidedBuildActionRunner.java:64)
      at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
      at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
      at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
      at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$3.run(RunAsBuildOperationBuildActionRunner.java:45)
      at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
      at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
      at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
      at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:97)
      at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
      at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:42)
      at org.gradle.tooling.internal.provider.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:51)
      at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:47)
      at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:31)
      at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:39)
      at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:25)
      at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:80)
      at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:53)
      at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:61)
      at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:34)
      at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36)
      at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25)
      at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:43)
      at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:29)
      at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:64)
      at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:29)
      at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:59)
      at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:44)
      at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:46)
      at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:30)
      at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
      at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
      at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
      at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
      at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
      at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
      at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
      at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
      at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
      at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
      at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
      at org.gradle.util.Swapper.swap(Swapper.java:38)
      at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
      at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
      at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
      at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
      at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:62)
      at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
      at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
      at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:82)
      at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
      at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
      at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
      at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:295)
      at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
      at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
      at java.lang.Thread.run(Thread.java:745)
  Caused by: org.gradle.process.internal.ExecException: A problem occurred starting process 'command 'security''
      at org.gradle.process.internal.DefaultExecHandle.execExceptionFor(DefaultExecHandle.java:226)
      at org.gradle.process.internal.DefaultExecHandle.setEndStateInfo(DefaultExecHandle.java:204)
      at org.gradle.process.internal.DefaultExecHandle.failed(DefaultExecHandle.java:349)
      at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:85)
      at org.gradle.internal.operations.CurrentBuildOperationPreservingRunnable.run(CurrentBuildOperationPreservingRunnable.java:42)
      ... 6 more
  Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'security'
      at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:27)
      at net.rubygrapefruit.platform.internal.WindowsProcessLauncher.start(WindowsProcessLauncher.java:22)
      at net.rubygrapefruit.platform.internal.WrapperProcessLauncher.start(WrapperProcessLauncher.java:36)
      at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:67)
      ... 7 more
  Caused by: java.io.IOException: Cannot run program "security" (in directory "C:\laragon\www\EDUWEB_MOBILE_APP-master\android\app"): CreateProcess error=2, The system cannot find the file specified
      at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
      at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:25)
      ... 10 more
  Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
      at java.lang.ProcessImpl.create(Native Method)
      at java.lang.ProcessImpl.&lt;init&gt;(ProcessImpl.java:386)
      at java.lang.ProcessImpl.start(ProcessImpl.java:137)
      at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
      ... 11 more
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>This is the build script for the module;</p>
  
  <pre><code>apply plugin: "com.android.application"
  
  import com.android.build.OutputFile
  
  /**
   * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
   * and bundleReleaseJsAndAssets).
   * These basically call `react-native bundle` with the correct arguments during the Android build
   * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
   * bundle directly from the development server. Below you can see all the possible configurations
   * and their defaults. If you decide to add a configuration block, make sure to add it before the
   * `apply from: "../../node_modules/react-native/react.gradle"` line.
   *
   * project.ext.react = [
   *   // the name of the generated asset file containing your JS bundle
   *   bundleAssetName: "index.android.bundle",
   *
   *   // the entry file for bundle generation
   *   entryFile: "index.android.js",
   *
   *   // whether to bundle JS and assets in debug mode
   *   bundleInDebug: false,
   *
   *   // whether to bundle JS and assets in release mode
   *   bundleInRelease: true,
   *
   *   // whether to bundle JS and assets in another build variant (if configured).
   *   // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
   *   // The configuration property can be in the following formats
   *   //         'bundleIn${productFlavor}${buildType}'
   *   //         'bundleIn${buildType}'
   *   // bundleInFreeDebug: true,
   *   // bundleInPaidRelease: true,
   *   // bundleInBeta: true,
   *
   *   // the root of your project, i.e. where "package.json" lives
   *   root: "../../",
   *
   *   // where to put the JS bundle asset in debug mode
   *   jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
   *
   *   // where to put the JS bundle asset in release mode
   *   jsBundleDirRelease: "$buildDir/intermediates/assets/release",
   *
   *   // where to put drawable resources / React Native assets, e.g. the ones you use via
   *   // require('./image.png')), in debug mode
   *   resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
   *
   *   // where to put drawable resources / React Native assets, e.g. the ones you use via
   *   // require('./image.png')), in release mode
   *   resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
   *
   *   // by default the gradle tasks are skipped if none of the JS files or assets change; this means
   *   // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
   *   // date; if you have any other folders that you want to ignore for performance reasons (gradle
   *   // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
   *   // for example, you might want to remove it from here.
   *   inputExcludes: ["android/**", "ios/**"],
   *
   *   // override which node gets called and with what additional arguments
   *   nodeExecutableAndArgs: ["node"]
   *
   *   // supply additional arguments to the packager
   *   extraPackagerArgs: []
   * ]
   */
  
  apply from: "../../node_modules/react-native/react.gradle"
  //apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
  
  /**
   * Set this to true to create two separate APKs instead of one:
   *   - An APK that only works on ARM devices
   *   - An APK that only works on x86 devices
   * The advantage is the size of the APK is reduced by about 4MB.
   * Upload all the APKs to the Play Store and people will download
   * the correct one based on the CPU architecture of their device.
   */
  def enableSeparateBuildPerCPUArchitecture = false
  
  /**
   * Run Proguard to shrink the Java bytecode in release builds.
   */
  def enableProguardInReleaseBuilds = true
  
  /**
   * Keystore password
   */
   def getPassword(String currentUser, String keyChain) {
      def stdout = new ByteArrayOutputStream()
      def stderr = new ByteArrayOutputStream()
      exec {
          commandLine 'security', '-q', 'find-generic-password', '-a', currentUser, '-s', keyChain, '-w'
          standardOutput = stdout
          errorOutput = stderr
          ignoreExitValue true
      }
      //noinspection GroovyAssignabilityCheck
         stdout.toString().trim()
   }
  def pass = getPassword("Some Name","android_keystore_testing")
  
  
  android {
      compileSdkVersion 23
      buildToolsVersion "23.0.2"
  
      defaultConfig {
          applicationId "com.eduwebparents"
          minSdkVersion 16
          targetSdkVersion 22
          versionCode 2
          versionName "2.0"
          ndk {
              abiFilters "armeabi-v7a", "x86"
          }
          manifestPlaceholders = [onesignal_app_id: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
                                  onesignal_google_project_number: "xxxxxxxxxxxx"]
      }
      signingConfigs {
          release {
              storeFile file(MYAPP_RELEASE_STORE_FILE)
              storePassword pass // Change this
              keyAlias MYAPP_RELEASE_KEY_ALIAS
              keyPassword pass // Change this
          }
      }
      splits {
          abi {
              reset()
              enable enableSeparateBuildPerCPUArchitecture
              universalApk false  // If true, also generate a universal APK
              include "armeabi-v7a", "x86"
          }
      }
      buildTypes {
          release {
              minifyEnabled enableProguardInReleaseBuilds
              proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
              signingConfig signingConfigs.release
          }
      }
      // applicationVariants are e.g. debug, release
      applicationVariants.all { variant -&gt;
          variant.outputs.each { output -&gt;
              // For each separate APK per architecture, set a unique version code as described here:
              // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
              def versionCodes = ["armeabi-v7a":1, "x86":2]
              def abi = output.getFilter(OutputFile.ABI)
              if (abi != null) {  // null for the universal-debug, universal-release variants
                  output.versionCodeOverride =
                          versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
              }
          }
      }
  }
  
  dependencies {
      //compile project(':react-native-html-to-pdf')
      //compile project(':react-native-pdf-view')
      compile project(':react-native-fetch-blob')
      compile project(':react-native-onesignal')
      compile project(':react-native-vector-icons')
      //compile project(':react-native-code-push')
      //compile project(':react-native-fs')
      //compile project(':react-native-file-opener')
      compile fileTree(dir: "libs", include: ["*.jar"])
      compile "com.android.support:appcompat-v7:23.0.1"
      compile "com.facebook.react:react-native:+"  // From node_modules
  }
  
  // Run this once to be able to run the application with BUCK
  // puts all compile dependencies into folder libs for BUCK to use
  task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
  }
  </code></pre>
  
  <p>And this is the build script for the app;</p>
  
  <pre><code>// Top-level build file where you can add configuration options common to all sub-projects/modules.
  
  buildscript {
      repositories {
          jcenter()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:2.2.2'
  
          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
      }
  }
  
  allprojects {
      repositories {
  mavenLocal()
  jcenter()
  }
  }
  </code></pre>