I've wrote a lint rule to be used in my Android Studio project. It is already working successfully. However, the tests are not running. Everytime I try to execute the tests, I receive the following error:
USE_PSI_CLASS_FILES_READING
java.lang.NoSuchFieldError: USE_PSI_CLASS_FILES_READING
at com.android.tools.lint.UastEnvironmentKt.createKotlinCompilerConfig(UastEnvironment.kt:310)
at com.android.tools.lint.UastEnvironmentKt.access$createKotlinCompilerConfig(UastEnvironment.kt:1)
at com.android.tools.lint.UastEnvironment$Configuration$Companion.create(UastEnvironment.kt:118)
at com.android.tools.lint.LintCliClient.initializeProjects(LintCliClient.kt:1349)
at com.android.tools.lint.client.api.LintClient.performInitializeProjects$lint_api(LintClient.kt:1012)
at com.android.tools.lint.client.api.LintDriver.initializeProjectRoots(LintDriver.kt:570)
at com.android.tools.lint.client.api.LintDriver.doAnalyze(LintDriver.kt:485)
at com.android.tools.lint.client.api.LintDriver.doAnalyze$default(LintDriver.kt:474)
at com.android.tools.lint.client.api.LintDriver.analyze(LintDriver.kt:418)
at com.android.tools.lint.checks.infrastructure.TestLintClient.analyze(TestLintClient.java:671)
at com.android.tools.lint.checks.infrastructure.TestLintClient.analyze(TestLintClient.java:602)
at com.android.tools.lint.checks.infrastructure.TestLintClient.checkLint(TestLintClient.java:349)
at com.android.tools.lint.checks.infrastructure.TestLintRunner.checkLint(TestLintRunner.kt:229)
at com.android.tools.lint.checks.infrastructure.TestLintRunner.run(TestLintRunner.kt:172)
at com.android.tools.lint.checks.infrastructure.TestLintTask.run(TestLintTask.java:933)
Basically, the error occurs everytime I call the run method of lint() in my tests:
lint().files(classFile)
.allowMissingSdk()
.run()
.expectWarningCount(1)
I executed the tests from Android Studio and by using ./gradlew lint-rules:test. In both cases the same error arises.
Thanks for your help!