IntDef and StringDef not being checked at compile time


While developing for Android we come across a lot of different annotation classes like IntDef and StringDef that effectively replace enums.

On Java that is no problem, as those annotations are checked in the compile time and we get suggestions and warnings based on that. Think of when you are setting the visibility of a view(in java) and the first suggestions are always INVISIBLE/GONE/VISIBLE, that is the power of IntDef. Programming for Kotlin? Then you always have to look up what is expected as input.

Now we can create the defs in Kotlin itself, which is great, but suggestions and warnings are still not there. Do we have some updates on that? am I missing something? Or what are your opinions on the subject?


This checking doesn’t come from the compiler, but from Android lint. Work to make android lint language independent is being done, but if I’m not mistaken you’ll need a newer version of Android Studio for it.


That makes more sense, thanks for answering. I guess I will try to write my own Lint rules if anything is still missing after the update :slight_smile: