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
This is a known issue, see KT-16506.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With