title: How to resolve "Obsolete custom lint check" for my custom IssueRegistry written in Kotlin and make it work (Android)
body: <p>I am trying to implement custom lint checks (using Kotlin). I have set up a module for my custom checks and added classes to test my first lew lint check, mostly following these two tutorials <a href="https://medium.com/@vanniktech/writing-your-first-lint-check-39ad0e90b9e6" rel="nofollow noreferrer">here</a> and <a href="https://jayrambhia.com/blog/android-lint" rel="nofollow noreferrer">here</a>.</p>
  <p>So I now have a module, I have a custom IssueRegistry, I've created an issue and a Detector class for it. So far it seems complete. I've added a test to check if my lint check works and it looks alright.</p>
  <p>I have added my module to the project by referencing it in settings.gradle like this: <code>include ':app', ':somemodule', ':mylintmodule'</code></p>
  <p>Now if I run the linter using <code>./gradlew lint</code> I get a lint result file telling me this:</p>
  <pre><code>    Lint found an issue registry (com.myproject.mylintmodule) which requires a newer API level. That means that the custom lint checks are intended for a newer lint version; please upgrade
      Lint can be extended with &quot;custom checks&quot;: additional checks implemented by developers and libraries to for example enforce specific API usages required by a library or a company coding style guideline.
  
      The Lint APIs are not yet stable, so these checks may either cause a performance degradation, or stop working, or provide wrong results.
  
      This warning flags custom lint checks that are found to be using obsolete APIs and will need to be updated to run in the current lint environment.
  
      It may also flag issues found to be using a newer version of the API, meaning that you need to use a newer version of lint (or Android Studio or Gradle plugin etc) to work with these checks.
      To suppress this error, use the issue id &quot;ObsoleteLintCustomCheck&quot; as explained in the Suppressing Warnings and Errors section.
  </code></pre>
  <p>So it tells me that I am using a newer API verion in my custom lint check, right? This is my custom IssueRegistry (minus some parts not relevant for this problem):</p>
  <pre><code>    class MyCustomIssueRegistry : IssueRegistry() {
          override val issues: List&lt;Issue&gt;
              get() = listOf(ISSUE_NAMING_PATTERN)
  
          override val api: Int = com.android.tools.lint.detector.api.CURRENT_API
          override val minApi: Int = 1 
  }
  </code></pre>
  <p>From googling this problem and finding <a href="https://github.com/JakeWharton/timber/issues/329" rel="nofollow noreferrer">this</a> issue I figured I have to override and set the right API version (and maybe the min API?) by overriding these properties like I did above (this version is my last attempt, directly taken from that issue).
  So this property can be set to values between -1 and 5, meaning this (taken right out of the lint.detector.api class):</p>
  <pre><code>
      /** Describes the given API level */
      fun describeApi(api: Int): String {
          return when (api) {
              5 -&gt; &quot;3.5+&quot; // 3.5.0-alpha07
              4 -&gt; &quot;3.4&quot; // 3.4.0-alpha03
              3 -&gt; &quot;3.3&quot; // 3.3.0-alpha12
              2 -&gt; &quot;3.2&quot; // 3.2.0-alpha07
              1 -&gt; &quot;3.1&quot; // Initial; 3.1.0-alpha4
              0 -&gt; &quot;3.0 and older&quot;
              -1 -&gt; &quot;Not specified&quot;
              else -&gt; &quot;Future: $api&quot;
          }
  
  </code></pre>
  <p>I have tried all of them, plus the one above adding a minApi override too, and I keep getting the exact same result for each of them.</p>
  <p>Also I am unable to locate what other API version this is compared with. Is there a place where this is set for the regular linter in an Android project?</p>
  <p>It's also unclear to me what I have to do to make sure my changes got applied - is it enough to change some code, then run lint, or do I have to compile the project first, or build &amp; clean?</p>
  <p>Following the tutorials, I added my custom lint check by adding this to the app's build.gradle: <code>lintChecks project(&quot;:mylintmodule&quot;)</code>
  Is that even right? The API issue on my registry class shows up no matter if my lint check is referenced (and hopefully used) like that or not. I have also tried the other method described in the first tutorial, adding this task to the linter module build.gradle:</p>
  <pre><code>
      defaultTasks 'assemble'
  
      task copyLintJar(type: Copy) {
          description = 'Copies the lint jar file into the {user.home}/.android/lint folder.'
          from('build/libs/')
          into(System.getProperty(&quot;user.home&quot;) + '/.android/lint')
          include(&quot;*.jar&quot;)
      }
  
      // Runs the copyLintJar task after build has completed.
      build.finalizedBy(copyLintJar)
  
  </code></pre>
  <p>But since I can't figure out how to see if my custom checks are actually run, I don't know if that works as intended either.</p>
  <p>So how do I get this warning resolved (since I interpret the text as &quot;As long as the versions don't match I will not try to run your lint check&quot;), and how can I make sure my lint check is actually run by the linter?</p>