LiveData. Cannot assign to ‘value’: the setter is protected/*protected and package*/ for synthetic extension

As @spkink suggested:

replace

fun getCurrentName(): LiveData<String>

with

fun getCurrentName(): MutableLiveData<String>

The error is caused because setValue(T value) is protected in LiveData (so you cannot call it) while it is public in MutableLiveData.

Leave a Comment