The error from the title is returned for the following code, which makes no sense
private val _error = MutableLiveData<String?>()
val error: LiveData<String?> get() = _error
_error.postValue(null) //Error Cannot set non-nullable LiveData value to null [NullSafeMutableLiveData]
parameter String
of _error
is obviously nullable, am I doing something wrong?
This appears to be related to a bug already reported against
androidx.lifecycle
pre-release of 2.3.0 https://issuetracker.google.com/issues/169249668.Workarounds I have found:
NullSafeMutableLiveData
inbuild.gradle
or
lint.xml
in root dirMutableLiveData
encapsulation via backing properties dance (which really hurts my eyes).