I have a publicly visible Int to hold the current application theme.
var themeId: Int = R.style.AppTheme
private set
If I annotate the value with @StyleRes
@StyleRes var themeId: Int = R.style.AppTheme
private set
I get a warning
This annotation does not apply for type void; expected int or long
If I change the variable to val
, the error is not displayed.
I can also get rid of the error by adding the @JvmField
annotation, but this removes the ability to have the private setter.
Am I using the annotation incorrectly, or is this a problem with Kotlin on Android Studio?
Edit:
The getter can be annotated
var themeId: Int = R.style.AppTheme
private set
@StyleRes get
@field:StyleRes
or@get:StyleRes
? – holi-javaprivate @StyleRes var themeId: Int = R.style.AppTheme
? – holi-java