I have a view with a viewModel that observes my LiveData. I get my data from a Repository (which gets data either from Room or WebAPI). I have implemented a NetworkBoundResource abstract class so I can manage data loading in a cleaner way. MediatorLiveData object is used in this class:
private final MediatorLiveData<Resource<ResultType>> result = new MediatorLiveData<>();
The crash happens at the first line of my constructor:
@MainThread
public NetworkBoundResource() {
result.setValue(Resource.<ResultType>loading(null));
final LiveData<ResultType> dbSource = loadFromDb();
result.addSource(dbSource, new Observer<ResultType>() {
@Override
public void onChanged(@Nullable ResultType newData) {
result.removeSource(dbSource);
if(shouldFetch(newData))
{
fetchFromNetwork(dbSource);
} else {
result.setValue(Resource.success(newData));
}
}
});
}
Here is the error message:
java.lang.NoSuchMethodError: No virtual method iteratorWithAdditions()Landroid/arch/core/internal/SafeIterableMap$ListIterator; in class Landroid/arch/core/internal/SafeIterableMap; or its super classes (declaration of 'android.arch.core.internal.SafeIterableMap' appears in /data/app/com.example.smostofi.upswing-XxPvhI837wneIYVTOrU2Dw==/split_lib_dependencies_apk.apk:classes25.dex)
at android.arch.lifecycle.LiveData.dispatchingValue(LiveData.java:145)
at android.arch.lifecycle.LiveData.setValue(LiveData.java:293)
at android.arch.lifecycle.MutableLiveData.setValue(MutableLiveData.java:33)
at com.example.smostofi.upswing.data.Util.NetworkBoundResource.<init>(NetworkBoundResource.java:44)
First time asking a question here, hopefully I provided enough info! Thanks in advance!