Lint - FAILURE:构建因异常而失败

时间:2017-11-01 19:15:14

标签: android lint gradlew

我想在我的项目上运行gradlew :lint

但是,我正在错误:

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

当我跑步时:gradlew lint

我得到错误

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

我无法在线搜索任何解决方案。

  

参考:https://developer.android.com/studio/write/lint.html

1 个答案:

答案 0 :(得分:0)

将JAVA_HOME变量设置为C:\Program Files\Java\jdkX.XX对我有用。

由于某种原因,它之前已设置为JRE目录。

将JAVA_HOME变量设置为C:\Program Files\Java\jdkX.XX

1)转到搜索栏并输入“环境”,然后单击“编辑系统环境变量”。 2)单击“环境变量”按钮 3)在System Variables标题下,单击“新建”。输入名称JAVA_HOME并查找jdk的路径,就像杰弗里所说的那样。单击“确定”并再次单击“确定”。

DOS窗口上的

echo %JAVA_HOME%