-1

I want to run gradlew :lint on my project.

But,I am getting Error:

C:\[ProjectName]>gradlew :lint
Starting a Gradle Daemon, 1 incompatible and 3 stopped Daemons could not be reused, use --status for details
Incremental java compilation is an incubating feature.

FAILURE: Build failed with an exception.

* What went wrong:
Task 'lint' not found in root project '[ProjectName]'. Some candidates are: 'init'.

* Try:
Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 1 mins 27.334 secs

When I run: gradlew lint

I get Error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Could not find tools.jar. Please check that C:\Program Files\Java\jre1.8.0_151 contains a valid JDK installation.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

I can't search for any solution online.

Refer: https://developer.android.com/studio/write/lint.html

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Beginner
  • 1,202
  • 2
  • 20
  • 29

1 Answers1

1

Setting the JAVA_HOME variable to C:\Program Files\Java\jdkX.XX worked for me.

It was previously set to the JRE directory for some reason.

Set JAVA_HOME variable to C:\Program Files\Java\jdkX.XX

1) go to Search bar and type in "environment" and click on "Edit the system environment variables". 2) click on "Environment Variables" button 3) under System Variables heading, click "new". Enter the name as JAVA_HOME and look up the path to the jdk like Jeffrey said. Click OK and OK again.

echo %JAVA_HOME% on a DOS window

Beginner
  • 1,202
  • 2
  • 20
  • 29