java.lang.IllegalStateException: *The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread.* [in ListView(-1, class android.widget.ListView) with Adapter(class android.widget.HeaderViewListAdapter)]

Appcelerator JIRA | Mark Mokryn | 3 years ago
  1. 0

    On occasion I am seeing app crashes with the log below. Unfortunately, I have not been able to reproduce this in a simple test case, but it does happen on occasion in my app, during certain sequences. The issue is clearly stated in the error log: the ListView has been modified outside the UI thread. Reviewing the ListView code, there are several places where such issues can occur. In ListSectionProxy.java, for example the following methods *definitely* modify the ListView without first making sure the UI thread is running: {{setHeaderView}}, {{setFooterView}}, {{setHeaderTitle}}, and {{setFooterTitle}}. And indeed - *the issues in my code went away* after I stopped calling {{setHeaderTitle}}. Note that these methods ensure the UI thread is running only to call {{adapter.notifyDataSetChanged()}}, but the changes themselves may clearly be made outside the UI thread - which is a bug. Additionally - I'm not sure that setting the ListView.sections property is UI thread safe. I strongly suggest Appcelerator reviews ListView code to ensure it is all UI thread safe. {color:red} 05-04 19:03:15.566: E/AndroidRuntime(9698): FATAL EXCEPTION: main 05-04 19:03:15.566: E/AndroidRuntime(9698): java.lang.IllegalStateException: *The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread.* [in ListView(-1, class android.widget.ListView) with Adapter(class android.widget.HeaderViewListAdapter)] 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.ListView.layoutChildren(ListView.java:1510) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.AbsListView.onLayout(AbsListView.java:1260) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.FrameLayout.onLayout(FrameLayout.java:338) 05-04 19:03:15.566: E/AndroidRuntime(9698): at ti.modules.titanium.ui.widget.listview.TiListView$ListViewWrapper.onLayout(TiListView.java:139) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175) 05-04 19:03:15.566: E/AndroidRuntime(9698): at org.appcelerator.titanium.view.TiCompositeLayout.onLayout(TiCompositeLayout.java:580) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.FrameLayout.onLayout(FrameLayout.java:338) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1589) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175) 05-04 19:03:15.566: E/AndroidRuntime(9698): at org.appcelerator.titanium.view.TiCompositeLayout.onLayout(TiCompositeLayout.java:580) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.FrameLayout.onLayout(FrameLayout.java:338) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.LinearLayout.onLayout(LinearLayout.java:1047) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.FrameLayout.onLayout(FrameLayout.java:338) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.LinearLayout.onLayout(LinearLayout.java:1047) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.FrameLayout.onLayout(FrameLayout.java:338) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.ViewRoot.performTraversals(ViewRoot.java:1140) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.ViewRoot.handleMessage(ViewRoot.java:1859) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.os.Handler.dispatchMessage(Handler.java:99) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.os.Looper.loop(Looper.java:130) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.app.ActivityThread.main(ActivityThread.java:3683) 05-04 19:03:15.566: E/AndroidRuntime(9698): at java.lang.reflect.Method.invokeNative(Native Method) 05-04 19:03:15.566: E/AndroidRuntime(9698): at java.lang.reflect.Method.invoke(Method.java:507) 05-04 19:03:15.566: E/AndroidRuntime(9698): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 05-04 19:03:15.566: E/AndroidRuntime(9698): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 05-04 19:03:15.566: E/AndroidRuntime(9698): at dalvik.system.NativeStart.main(Native Method) {color}

    Appcelerator JIRA | 3 years ago | Mark Mokryn
    java.lang.IllegalStateException: *The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread.* [in ListView(-1, class android.widget.ListView) with Adapter(class android.widget.HeaderViewListAdapter)]
  2. 0

    On occasion I am seeing app crashes with the log below. Unfortunately, I have not been able to reproduce this in a simple test case, but it does happen on occasion in my app, during certain sequences. The issue is clearly stated in the error log: the ListView has been modified outside the UI thread. Reviewing the ListView code, there are several places where such issues can occur. In ListSectionProxy.java, for example the following methods *definitely* modify the ListView without first making sure the UI thread is running: {{setHeaderView}}, {{setFooterView}}, {{setHeaderTitle}}, and {{setFooterTitle}}. And indeed - *the issues in my code went away* after I stopped calling {{setHeaderTitle}}. Note that these methods ensure the UI thread is running only to call {{adapter.notifyDataSetChanged()}}, but the changes themselves may clearly be made outside the UI thread - which is a bug. Additionally - I'm not sure that setting the ListView.sections property is UI thread safe. I strongly suggest Appcelerator reviews ListView code to ensure it is all UI thread safe. {color:red} 05-04 19:03:15.566: E/AndroidRuntime(9698): FATAL EXCEPTION: main 05-04 19:03:15.566: E/AndroidRuntime(9698): java.lang.IllegalStateException: *The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread.* [in ListView(-1, class android.widget.ListView) with Adapter(class android.widget.HeaderViewListAdapter)] 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.ListView.layoutChildren(ListView.java:1510) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.AbsListView.onLayout(AbsListView.java:1260) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.FrameLayout.onLayout(FrameLayout.java:338) 05-04 19:03:15.566: E/AndroidRuntime(9698): at ti.modules.titanium.ui.widget.listview.TiListView$ListViewWrapper.onLayout(TiListView.java:139) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175) 05-04 19:03:15.566: E/AndroidRuntime(9698): at org.appcelerator.titanium.view.TiCompositeLayout.onLayout(TiCompositeLayout.java:580) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.FrameLayout.onLayout(FrameLayout.java:338) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1589) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175) 05-04 19:03:15.566: E/AndroidRuntime(9698): at org.appcelerator.titanium.view.TiCompositeLayout.onLayout(TiCompositeLayout.java:580) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.FrameLayout.onLayout(FrameLayout.java:338) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.LinearLayout.onLayout(LinearLayout.java:1047) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.FrameLayout.onLayout(FrameLayout.java:338) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.LinearLayout.onLayout(LinearLayout.java:1047) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.FrameLayout.onLayout(FrameLayout.java:338) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.ViewRoot.performTraversals(ViewRoot.java:1140) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.ViewRoot.handleMessage(ViewRoot.java:1859) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.os.Handler.dispatchMessage(Handler.java:99) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.os.Looper.loop(Looper.java:130) 05-04 19:03:15.566: E/AndroidRuntime(9698): at android.app.ActivityThread.main(ActivityThread.java:3683) 05-04 19:03:15.566: E/AndroidRuntime(9698): at java.lang.reflect.Method.invokeNative(Native Method) 05-04 19:03:15.566: E/AndroidRuntime(9698): at java.lang.reflect.Method.invoke(Method.java:507) 05-04 19:03:15.566: E/AndroidRuntime(9698): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 05-04 19:03:15.566: E/AndroidRuntime(9698): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 05-04 19:03:15.566: E/AndroidRuntime(9698): at dalvik.system.NativeStart.main(Native Method) {color}

    Appcelerator JIRA | 3 years ago | Mark Mokryn
    java.lang.IllegalStateException: *The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread.* [in ListView(-1, class android.widget.ListView) with Adapter(class android.widget.HeaderViewListAdapter)]
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    Failed to read row 0, column 1 from a CursorWindow which has 1 rows, 1 columns

    Stack Overflow | 1 year ago | Androiddv
    java.lang.IllegalStateException: Couldn't read row 0, col 1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it. 08-06 04:46:26.073 4206-4206/? W/System.err﹕ at android.database.CursorWindow.nativeGetString(Native Method) 08-06 04:46:26.073 4206-4206/? W/System.err﹕ at android.database.CursorWindow.getString(CursorWindow.java:434) 08-06 04:46:26.073 4206-4206/? W/System.err﹕ at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:51) 08-06 04:46:26.073 4206-4206/? W/System.err﹕ at com.example.tazeen.classnkk.AllPosts_Page.getActivityObjectId(AllPosts_Page.java:627) 08-06 04:46:26.073 4206-4206/? W/System.err﹕ at com.example.tazeen.classnkk.AllPosts_Page.access$100(AllPosts_Page.java:72) 08-06 04:46:26.083 4206-4206/? W/System.err﹕ at com.example.tazeen.classnkk.AllPosts_Page$MyListAdapter.getView(AllPosts_Page.java:483) 08-06 04:46:26.083 4206-4206/? W/System.err﹕ at android.widget.AbsListView.obtainView(AbsListView.java:2177) 08-06 04:46:26.093 4206-4206/? W/System.err﹕ at android.widget.ListView.makeAndAddView(ListView.java:1840) 08-06 04:46:26.093 4206-4206/? W/System.err﹕ at android.widget.ListView.fillDown(ListView.java:675) 08-06 04:46:26.103 4206-4206/? W/System.err﹕ at android.widget.ListView.fillFromTop(ListView.java:736) 08-06 04:46:26.103 4206-4206/? W/System.err﹕ at android.widget.ListView.layoutChildren(ListView.java:1655) 08-06 04:46:26.103 4206-4206/? W/System.err﹕ at android.widget.AbsListView.onLayout(AbsListView.java:2012) 08-06 04:46:26.103 4206-4206/? W/System.err﹕ at android.view.View.layout(View.java:14289) 08-06 04:46:26.123 4206-4206/? W/System.err﹕ at android.view.ViewGroup.layout(ViewGroup.java:4562) 08-06 04:46:26.123 4206-4206/? W/System.err﹕ at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671) 08-06 04:46:26.123 4206-4206/? W/System.err﹕ at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525) 08-06 04:46:26.133 4206-4206/? W/System.err﹕ at android.widget.LinearLayout.onLayout(LinearLayout.java:1434) 08-06 04:46:26.143 4206-4206/? W/System.err﹕ at android.view.View.layout(View.java:14289) 08-06 04:46:26.143 4206-4206/? W/System.err﹕ at android.view.ViewGroup.layout(ViewGroup.java:4562) 08-06 04:46:26.143 4206-4206/? W/System.err﹕ at android.widget.FrameLayout.onLayout(FrameLayout.java:448) 08-06 04:46:26.153 4206-4206/? W/System.err﹕ at android.view.View.layout(View.java:14289) 08-06 04:46:26.153 4206-4206/? W/System.err﹕ at android.view.ViewGroup.layout(ViewGroup.java:4562) 08-06 04:46:26.153 4206-4206/? W/System.err﹕ at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
  5. 0

    Failed to read row 0, column 1 from a CursorWindow which has 1 rows, 1 columns

    wtheme.co | 1 year ago
    java.lang.IllegalStateException: Couldn't read row 0, col 1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it. 08-06 04:46:26.073 4206-4206/? W/System.err﹕ at android.database.CursorWindow.nativeGetString(Native Method) 08-06 04:46:26.073 4206-4206/? W/System.err﹕ at android.database.CursorWindow.getString(CursorWindow.java:434) 08-06 04:46:26.073 4206-4206/? W/System.err﹕ at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:51) 08-06 04:46:26.073 4206-4206/? W/System.err﹕ at com.example.tazeen.classnkk.AllPosts_Page.getActivityObjectId(AllPosts_Page.java:627) 08-06 04:46:26.073 4206-4206/? W/System.err﹕ at com.example.tazeen.classnkk.AllPosts_Page.access$100(AllPosts_Page.java:72) 08-06 04:46:26.083 4206-4206/? W/System.err﹕ at com.example.tazeen.classnkk.AllPosts_Page$MyListAdapter.getView(AllPosts_Page.java:483) 08-06 04:46:26.083 4206-4206/? W/System.err﹕ at android.widget.AbsListView.obtainView(AbsListView.java:2177) 08-06 04:46:26.093 4206-4206/? W/System.err﹕ at android.widget.ListView.makeAndAddView(ListView.java:1840) 08-06 04:46:26.093 4206-4206/? W/System.err﹕ at android.widget.ListView.fillDown(ListView.java:675) 08-06 04:46:26.103 4206-4206/? W/System.err﹕ at android.widget.ListView.fillFromTop(ListView.java:736) 08-06 04:46:26.103 4206-4206/? W/System.err﹕ at android.widget.ListView.layoutChildren(ListView.java:1655) 08-06 04:46:26.103 4206-4206/? W/System.err﹕ at android.widget.AbsListView.onLayout(AbsListView.java:2012) 08-06 04:46:26.103 4206-4206/? W/System.err﹕ at android.view.View.layout(View.java:14289) 08-06 04:46:26.123 4206-4206/? W/System.err﹕ at android.view.ViewGroup.layout(ViewGroup.java:4562) 08-06 04:46:26.123 4206-4206/? W/System.err﹕ at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671) 08-06 04:46:26.123 4206-4206/? W/System.err﹕ at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525) 08-06 04:46:26.133 4206-4206/? W/System.err﹕ at android.widget.LinearLayout.onLayout(LinearLayout.java:1434) 08-06 04:46:26.143 4206-4206/? W/System.err﹕ at android.view.View.layout(View.java:14289) 08-06 04:46:26.143 4206-4206/? W/System.err﹕ at android.view.ViewGroup.layout(ViewGroup.java:4562) 08-06 04:46:26.143 4206-4206/? W/System.err﹕ at android.widget.FrameLayout.onLayout(FrameLayout.java:448) 08-06 04:46:26.153 4206-4206/? W/System.err﹕ at android.view.View.layout(View.java:14289) 08-06 04:46:26.153 4206-4206/? W/System.err﹕ at android.view.ViewGroup.layout(ViewGroup.java:4562) 08-06 04:46:26.153 4206-4206/? W/System.err﹕ at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalStateException

      *The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread.* [in ListView(-1, class android.widget.ListView) with Adapter(class android.widget.HeaderViewListAdapter)]

      at android.widget.ListView.layoutChildren()
    2. Android Platform
      FrameLayout.onLayout
      1. android.widget.ListView.layoutChildren(ListView.java:1510)
      2. android.widget.AbsListView.onLayout(AbsListView.java:1260)
      3. android.view.View.layout(View.java:7175)
      4. android.widget.FrameLayout.onLayout(FrameLayout.java:338)
      4 frames
    3. ti.modules.titanium
      TiListView$ListViewWrapper.onLayout
      1. ti.modules.titanium.ui.widget.listview.TiListView$ListViewWrapper.onLayout(TiListView.java:139)
      1 frame
    4. Android Platform
      View.layout
      1. android.view.View.layout(View.java:7175)
      1 frame
    5. org.appcelerator.titanium
      TiCompositeLayout.onLayout
      1. org.appcelerator.titanium.view.TiCompositeLayout.onLayout(TiCompositeLayout.java:580)
      1 frame
    6. Android Platform
      View.layout
      1. android.view.View.layout(View.java:7175)
      2. android.widget.FrameLayout.onLayout(FrameLayout.java:338)
      3. android.view.View.layout(View.java:7175)
      3 frames
    7. Android Support v4
      ViewPager.onLayout
      1. android.support.v4.view.ViewPager.onLayout(ViewPager.java:1589)
      1 frame
    8. Android Platform
      View.layout
      1. android.view.View.layout(View.java:7175)
      1 frame
    9. org.appcelerator.titanium
      TiCompositeLayout.onLayout
      1. org.appcelerator.titanium.view.TiCompositeLayout.onLayout(TiCompositeLayout.java:580)
      1 frame
    10. Android Platform
      ActivityThread.main
      1. android.view.View.layout(View.java:7175)
      2. android.widget.FrameLayout.onLayout(FrameLayout.java:338)
      3. android.view.View.layout(View.java:7175)
      4. android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
      5. android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
      6. android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
      7. android.view.View.layout(View.java:7175)
      8. android.widget.FrameLayout.onLayout(FrameLayout.java:338)
      9. android.view.View.layout(View.java:7175)
      10. android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
      11. android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
      12. android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
      13. android.view.View.layout(View.java:7175)
      14. android.widget.FrameLayout.onLayout(FrameLayout.java:338)
      15. android.view.View.layout(View.java:7175)
      16. android.view.ViewRoot.performTraversals(ViewRoot.java:1140)
      17. android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
      18. android.os.Handler.dispatchMessage(Handler.java:99)
      19. android.os.Looper.loop(Looper.java:130)
      20. android.app.ActivityThread.main(ActivityThread.java:3683)
      20 frames
    11. Java RT
      Method.invoke
      1. java.lang.reflect.Method.invokeNative(Native Method)
      2. java.lang.reflect.Method.invoke(Method.java:507)
      2 frames
    12. Android
      ZygoteInit.main
      1. com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
      2. com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
      2 frames
    13. Android Platform
      NativeStart.main
      1. dalvik.system.NativeStart.main(Native Method)
      1 frame