Tom Bom
Tom Bom

Reputation: 1721

React Native: A problem occurred evaluating project ':app' when trying to run on Android

I have a react native app and when I try to run it on my android device i get the following error:

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/myname/Desktop/myapp/android/app/build.gradle' line: 1

* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.application']
   > java.nio.file.AccessDeniedException: /Users/myname/.android/build-cache.lock

I'm using the following versions:

I tried to change Gradle versions but it didn't work. This is my app/build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "27.0.3"
        minSdkVersion = 16
        compileSdkVersion = 27
        targetSdkVersion = 26
        supportLibVersion = "27.1.1"
    }
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        google()
    }
}
task wrapper(type: Wrapper) {
    gradleVersion = '4.4'
    distributionUrl = distributionUrl.replace("bin", "all")
}

Upvotes: 6

Views: 53923

Answers (2)

Codemaker2015
Codemaker2015

Reputation: 1

You need to update to the latest gradle version to solve this issue.

  • Upgrade gradle build tools version in the project level build.gradle to 4.0.0 or higher

    buildscript {
      dependencies {
          classpath 'com.android.tools.build:gradle:4.0.0'
          ...
      }
    }
    
  • Upgrade the gradle version in the YourProject > gradle > wrapper > gradle-wrapper.properties to 6.0.0 or higher.

    distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
    

Upvotes: 0

Sagar Bhatnagar
Sagar Bhatnagar

Reputation: 484

1.Upgrade your gradle to :-

buildscript {
dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
}

2.Delete gradle cache files. It can be in path like C:\Users\username.gradle\caches for windows users. For Unix like sys it will be ~.gradle\caches

Upvotes: 8

Related Questions