A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution

前端 未结 30 1810
南旧
南旧 2020-12-12 20:01

All of sudden I start getting this error, and I am not getting idea why if anyone just let me know where this error is, will be enough helpful. As much I am able to get is t

30条回答
  •  独厮守ぢ
    2020-12-12 20:45

    Shout Out to @Rene Spies' answer above, I also got this error while working with databinding. It turns out the build engine doesn't like it when you put the @Bindable annotation on a field in the primary constructor of a data class in Kotlin.

    So never do the following,

    data class MyAwesomePojo(
        @Bindable
        var firstname: String,
        var lastname: String
    )
    

    instead what you need to do is

    data class MyCorrectAwesomePojo(
        var lastname: String
    ):{
        @get:Bindable
        var firstname: String
            set(value){
                field = value
            }
    }
    

    Bonus: remember to check for same values before setting value to field if you are trying to use two-way binding like me to prevent infinite looping of setting and getting.

提交回复
热议问题