3

I am applying the lint project as follows to a app module where there are issues but non of the issues are detected.

lintChecks project(':customlint')

ImportsIssueRegistry.kt

class ImportsIssueRegistry : IssueRegistry() {
    override val issues: List<Issue>
        get() = listOf(
            SyntheticImportIssue.ISSUE,
            AndroidLogImportIssue.ISSUE
        )

    override val api: Int
        get() = CURRENT_API
}

customlint/build.gradle

apply plugin: 'java-library'
apply plugin: 'kotlin'


ext.lintVersion = '26.4.2'

dependencies {

    //noinspection DifferentStdlibGradleVersion
    compileOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

    compileOnly "com.android.tools.lint:lint-api:$lintVersion"
    compileOnly "com.android.tools.lint:lint-checks:$lintVersion"

    testImplementation 'junit:junit:4.13-beta-3'
    testImplementation "com.android.tools.lint:lint:$lintVersion"
    testImplementation "com.android.tools.lint:lint-tests:$lintVersion"
    testImplementation "com.android.tools:testutils:$lintVersion"
}

sourceCompatibility = "1.8"
targetCompatibility = "1.8"

jar{
    manifest{
        attributes 'Lint-Registry-V2': '[package name].ImportsIssueRegistry'
    }
}

What I tried?

  • Checking the gradle version? I have the latest version (3.4.2)
  • Tried changing: Lint-Registry to Lint-Registry-V2 in customlint module
  • Also tried adding generated jar as following to the module's build.gradle : lintChecks fileTree(dir: 'libs', include: ['customlint.jar'] )

Update:

Full code can be found here

Someone please help.

user158
  • 12,852
  • 7
  • 62
  • 94

3 Answers3

3

I had the same problem, but it was cause by a missing apply plugin: 'kotlin' in the build.gradle for the lint rules' build.gradle, which is not your problem.

But you might want to catch up with the latest version of the API, with this video from ADS. Google really should update their documentations

Some notable differences:

  • declare registry in a resources file
  • AGP 3.5.1
Louis Tsai
  • 1,587
  • 3
  • 20
  • 33
0

Try using lintPublish project(':customlint') instead of lintChecks project(':customlint'). At the time of writing, Google's sample is out of date.

Justin Brooks
  • 99
  • 2
  • 6
  • appreciate trying to help, but it does not work. I updated the question and include the link the repo, you may take a look – user158 Sep 17 '19 at 03:12
0

I think you can remove any jar / Lint-Registry stuff

Have a look here: https://github.com/tikurahul/lint-experiments

Copy the NoisyDetector to help check that your setup is correct.

Raz
  • 458
  • 4
  • 11