Abhi
Abhi

Reputation: 19

Task :app:compileDebugJavaWithJavac FAILED React native

I am new in react native facing some issues

Starting a Gradle Daemon, 1 busy and 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

Task :app:compileDebugJavaWithJavac FAILED 15 actionable tasks: 2 executed, 13 up-to-date

FAILURE: Build failed with an exception.

Could not create service of type DefaultGeneralCompileCaches using GradleScopeCompileServices.createGeneralCompileCaches(). Unexpected lock protocol found in lock file. Expected 3, found 0.

BUILD FAILED in 3m 21s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

Could not create service of type DefaultGeneralCompileCaches using GradleScopeCompileServices.createGeneralCompileCaches(). Unexpected lock protocol found in lock file. Expected 3, found 0.

BUILD FAILED in 3m 21s

at makeError (C:\Users\RDX\Desktop\AwesomeProject\node_modules\execa\index.js:174:9)
at C:\Users\RDX\Desktop\AwesomeProject\node_modules\execa\index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async runOnAllDevices (C:\Users\RDX\Desktop\AwesomeProject\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)
at async Command.handleAction (C:\Users\RDX\Desktop\AwesomeProject\node_modules\@react-native-community\cli\build\index.js:186:9)

info Run CLI with --verbose flag for more details.

Upvotes: 1

Views: 13353

Answers (1)

Alish Giri
Alish Giri

Reputation: 2246

More information is needed here but you can try the following quick fixes.

Please note that the below terminal commands are based on Mac and Linux operating systems.

Run npx react-native run-android after each command below to see which fix works for you.

FIX-1:: Clean stale build & start a fresh one

  cd ./android && ./gradlew clean && cd ..

FIX-2:: Re-install project packages

  rm -rf ./node_modules
  npm install or yarn install

FIX-3:: Update your Gradle (Gradle is an android build system).

  1. Run this command again,

      cd ./android && ./gradlew clean && cd ..
    
  2. Update distributionUrl on android/gradle/wrapper/gradle-wrapper.properties to,

distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
  1. Update gradle tools version on android/build.gradle

    buildscript {
      ...
      dependencies {
          ...
          classpath('com.android.tools.build:gradle:4.2.0') // Use this verison
    

NOTE: Each command above should be executed from the project root folder. If none of these works then please leave a comment!

Upvotes: 2

Related Questions