I implemented a room database for my android app. It fills the databse asynchronously with a test item, which seems to work so far. Now I want to implement a listener that dynamically updates the UI if the data changes. But my listener makes the app crash on startup. This is my listener in the activity:
LiveData<List<Cat>> CatLiveData = Manager.getDB().getCatDAO().getCats();
CatLiveData. observe(this, new Observer<List<Cat>>() {
@Override
public void onChanged(@Nullable List<Cat> Cats) {
//Update your UI here.
binding.myControl.setText(Cats.get(0).getsName().toString());
}
});
It is supposed to fetch the very first element of the Cats-list and return its name property. The myControl is supposed to show this property. Check for null does not solve the crash.
Thanks a lot!
Edit: This is the LOgCat
01-23 22:18:00.863 9633-9633/? I/art: Late-enabling -Xcheck:jni 01-23 22:18:00.931 9633-9640/? I/art: Debugger is no longer active 01-23 22:18:00.931 9633-9640/? I/art: Starting a blocking GC Instrumentation 01-23 22:18:01.377 9633-9633/? W/System: ClassLoader referenced unknown path: /mnt/expand/27c5fc5f-9c8e-4173-8379-f18e8d4cf183/app/com.example.erik.test-1/lib/arm 01-23 22:18:01.411 9633-9633/? I/InstantRun: starting instant run server: is main process 01-23 22:18:01.612 9633-9633/? W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable 01-23 22:18:02.213 9633-9652/com.example.erik.test I/Adreno-EGL: : EGL 1.4 QUALCOMM build: Nondeterministic_AU_msm8974_LA.BF.1.1.3_RB1__release_AU (I389a668de0) OpenGL ES Shader Compiler Version: E031.28.00.04 Build Date: 10/24/15 Sat Local Branch: mybranch15621148 Remote Branch: quic/LA.BF.1.1.3_rb1.3 Local Patches: NONE Reconstruct Branch: NOTHING 01-23 22:18:02.217 9633-9652/com.example.erik.test I/OpenGLRenderer: Initialized EGL, version 1.4 01-23 22:18:02.217 9633-9652/com.example.erik.test D/OpenGLRenderer: Swap behavior 1 01-23 22:18:02.267 9633-9633/com.example.erik.test D/AndroidRuntime: Shutting down VM 01-23 22:18:02.268 9633-9633/com.example.erik.test E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.erik.test, PID: 9633 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 /mnt/expand/27c5fc5f-9c8e-4173-8379-f18e8d4cf183/app/com.example.erik.test-1/split_lib_dependencies_apk.apk) at android.arch.lifecycle.LiveData.dispatchingValue(LiveData.java:145) at android.arch.lifecycle.LiveData.setValue(LiveData.java:293) at android.arch.lifecycle.LiveData$2.run(LiveData.java:108) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6186) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)