I am unable to get the ViewModel component to work with Proguard. I already had to add the following to prevent a crash due to NoSuchMethodException: init ()
-keep class com .... SlideshowViewModel {*;}
However, my observers in activity do not receive any data. This works fine until I turn on Proguard, so I know that Proguard is the reason, I just don't know why (new to Proguardian here). What rule needs to be added to make observables work?
I have the following in my ViewModel (Kotlin)
val currentItem = MediatorLiveData<MediaItem>()
.... later...
Timber.d("Setting next image: " + position + " out of " + mediaItemList.size) currentItem.value = mediaItemList[position]
and activity (Java)
viewModel.getCurrentItem().observe(this, new Observer<MediaItem>() { @Override public void onChanged(@Nullable final MediaItem mediaItem) { Timber.d("Activity received new item"); } });
In the log I get: D / SlideshowViewModel: setting the following image: 0 of 18
But nothing happens in the onChanged Observable.
source share