java.lang.IllegalStateException: Illegal State: Table is closed, and no longer valid to operate on.
I got this error. The stacktrace is not useful either.
java.lang.IllegalStateException: Illegal State: Table is closed, and no longer valid to operate on.
at io.realm.internal.TableView.nativeSize(Native Method)
at io.realm.internal.TableView.size(TableView.java:129)
at io.realm.RealmResults.size(RealmResults.java:209)
at io.realm.RealmBaseAdapter.getCount(RealmBaseAdapter.java:52)
at android.widget.HeaderViewListAdapter.getCount(HeaderViewListAdapter.java:132)
at android.widget.ListView.onMeasure(ListView.java:1151)
at android.view.View.measure(View.java:17430)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:727)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:463)
at android.view.View.measure(View.java:17430)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
at android.view.View.measure(View.java:17430)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:447)
at android.view.View.measure(View.java:17430)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2560)
at android.view.View.measure(View.java:17430)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2001)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1166)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1372)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1054)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5779)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
at android.view.Choreographer.doCallbacks(Choreographer.java:580)
at android.view.Choreographer.doFrame(Choreographer.java:550)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Can you provide any context or code? It appears that you are accessing an object (from a Table) that has been closed. Are you by any chance holding on to and using a reference after the Realm has been closed()?
@ImGauravC Did you find out was was wrong? As @bmunkholm wrote, accessing a closed RealmResult might be the most likely error.
Please reopen the issue if this is not solved by using close().
I think that it would be much easier for developers to implement and manage the RealmResults objects if it would somehow hold the Realm object that created it and would close that realm in the destructor automatically... I would prefer this approach rather than catch exceptions all the time. This way the Adapters would work without managing the realm objects that have created them as well...