CheckStyle出现Unable to create a Checker configLocation问题

CheckStyle出现Unable to create a Checker: configLocation问题

最近使用了Android Studio 3.0版本,同时Gradle版本由3.3升级到了3.5版本。


1: Task failed with an exception.
* What went wrong:
Execution failed for task ':app:checkstyle'.
> Unable to create Root Module: configLocation {xxxx/xxxx/checkstyle/checkstyle.xml}, classpath {null}.



The specific problem here is that OperatorWrap did not support the METHOD_REF token until Checkstyle 7.2. Technically this configuration file is invalid unless you specify Checkstyle version 7.2 or higher.

With Gradle 3.3 (default Checkstyle 5.9), that configuration was still not correct, but you did not receive an error due to looser validation (in Checkstyle, not Gradle). That version only failed on tokens that were completely unknown, not those that were only valid for other rules.



apply plugin: 'checkstyle'

checkstyle {
    toolVersion = '5.9'

task checkstyle(type: Checkstyle) {
    configFile file("checkstyle.xml")

    ignoreFailures false
    showViolations true

    source 'src'
    include '**/*.java'
    exclude '**/gen/**', '**/test/**', '**/build/**'

    classpath = files()


文章作者: 流水不腐小夏
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 流水不腐小夏 !