Kotlin and android lint checks

2019-03-24 18:05发布

问题:

I am really loving to code android apps in Kotlin recently - but I really miss lint. Anyone knows how to get this back ( at least partially ). Is there a project that adapts the android java lint rules to kotlin? AFAIK lint is not running on bytecode only so there needs to be some manual converting to be done. My main pain-point at the moment is that I need a compile-time error when I use a function < MINSDK level Can someone point me in the right direction?

回答1:

The Kotlin team is working on supporting Android Lint checks for Kotlin code. You can watch this issue to keep track of the progress.



回答2:

In the release of Android Studio 3.2, Lint can able to check.

Follow below step to enable lint check for Kotlin:

  • To enable these checks, go to File > Preferences > Editor > Inspections and check the rules that you want to enable under Kotlin Interoperability, as shown below.

  • You can then run the checks by selecting Analyze > Inspect Code from the main menu.

Check more info at Lint checks for Java/Kotlin interoperability

I hope it helps us.



回答3:

There is a Kotlin linter that has a few different ways of integrating it with different build systems.

https://github.com/shyiko/ktlint