Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1269] App crashed and the crash log show "This view's id is id/0x65".

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionDuplicate
Resolution Date2014-07-31T00:32:02.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsandroid, defect
ReporterMinglei Chen
AssigneeShuo Liang
Created2014-07-20T14:02:36.000+0000
Updated2016-03-08T07:37:39.000+0000

Description

I met a crash while the crash log show below: {quote} java.lang.RuntimeException: Unable to start activity :java.lang.IllegalArgumentException: Wrong state class, expecting View State but received class android.widget.AbsListView$SavedState instead. This usually happens when two views of different type have the same id in the same hierarchy. This view's id is id/0x65. Make sure other views do not use the same id. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2317) at android.app.ActivityThread.access$600(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1299) at android.os.Handler.dispatchMessage(Handler.java:99) {quote} After analysis, I found that crash caused by a magic number 101(0x65), code like below. 1. {quote} public class TiTableView extends FrameLayout implements OnSearchChangeListener { {color:red}public static final int TI_TABLE_VIEW_ID = 101;{color} private static final String TAG = "TiTableView"; {quote} 2. {quote} public class TiTableViewHeaderItem extends TiBaseTableViewItem { private RowView rowView; private TiUIView headerView; private boolean isHeaderView = false; class RowView extends RelativeLayout { private TextView textView; private Item item; public RowView(Context context) { super(context); setGravity(Gravity.CENTER_VERTICAL); textView = new TextView(context); {color:red}textView.setId(101);{color} {quote} While the App hide in background, for any reason(like system GC), part of app memory released. At this time when the app re-launch from background, it will trigger onRestoreInstanceState, like below logs with 101=xxxx, it must be one of user-defined component, but both system and user-defined ids repetition, crash happen: {quote} [INFO] : TiRootActivity: (main) [0,0] checkpoint, on root activity create, savedInstanceState: Bundle[{android:viewHierarchyState=Bundle[{android:views={7=android.view.AbsSavedState$1@41959308, 12=android.view.AbsSavedState$1@41959308, 13=android.view.AbsSavedState$1@41959308, 14=android.view.AbsSavedState$1@41959308, 15=android.view.AbsSavedState$1@41959308, 16=android.view.AbsSavedState$1@41959308, 17=android.view.AbsSavedState$1@41959308, 18=android.view.AbsSavedState$1@41959308, 19=android.view.AbsSavedState$1@41959308, 20=android.view.AbsSavedState$1@41959308, 21=android.view.AbsSavedState$1@41959308, 22=android.view.AbsSavedState$1@41959308, 23=android.view.AbsSavedState$1@41959308, 24=android.view.AbsSavedState$1@41959308, 25=android.view.AbsSavedState$1@41959308, 26=android.view.AbsSavedState$1@41959308, 27=android.view.AbsSavedState$1@41959308, 28=android.view.AbsSavedState$1@41959308, 29=android.view.AbsSavedState$1@41959308, 30=android.view.AbsSavedState$1@41959308, 31=android.view.AbsSavedState$1@41959308, 32=android.view.AbsSavedState$1@41959308, 33=android.view.AbsSavedState$1@41959308, 34=android.view.AbsSavedState$1@41959308, 35=android.view.AbsSavedState$1@41959308, 36=android.view.AbsSavedState$1@41959308, 37=android.view.AbsSavedState$1@41959308, 38=android.view.AbsSavedState$1@41959308, 39=android.view.AbsSavedState$1@41959308, 41=android.view.AbsSavedState$1@41959308, 42=android.view.AbsSavedState$1@41959308, 43=android.view.AbsSavedState$1@41959308, 44=android.view.AbsSavedState$1@41959308, 45=android.view.AbsSavedState$1@41959308, 46=android.view.AbsSavedState$1@41959308, 47=android.view.AbsSavedState$1@41959308, 48=android.view.AbsSavedState$1@41959308, 49=android.view.AbsSavedState$1@41959308, 50=android.view.AbsSavedState$1@41959308, 51=android.view.AbsSavedState$1@41959308, 52=android.view.AbsSavedState$1@41959308, 53=android.view.AbsSavedState$1@41959308, 54=android.view.AbsSavedState$1@41959308, 55=android.view.AbsSavedState$1@41959308, 56=android.view.AbsSavedState$1@41959308, 57=android.view.AbsSavedState$1@41959308, 58=android.view.AbsSavedState$1@41959308, 59=android.view.AbsSavedState$1@41959308, 60=android.view.AbsSavedState$1@41959308, 61=android.view.AbsSavedState$1@41959308, 63=android.view.AbsSavedState$1@41959308, 64=TextView.SavedState{44f7b300 start=0 end=0 text= locale=zh-TW}, 65=android.view.AbsSavedState$1@41959308, 66=android.view.AbsSavedState$1@41959308, 68=android.view.AbsSavedState$1@41959308, 69=android.view.AbsSavedState$1@41959308, 70=android.view.AbsSavedState$1@41959308, 71=android.view.AbsSavedState$1@41959308, 72=android.view.AbsSavedState$1@41959308, 73=android.view.AbsSavedState$1@41959308, 74=android.view.AbsSavedState$1@41959308, 75=android.view.AbsSavedState$1@41959308, 76=android.view.AbsSavedState$1@41959308, 77=android.view.AbsSavedState$1@41959308, 78=android.view.AbsSavedState$1@41959308, 79=android.view.AbsSavedState$1@41959308, 80=android.view.AbsSavedState$1@41959308, 81=android.view.AbsSavedState$1@41959308, 82=android.view.AbsSavedState$1@41959308, 83=android.view.AbsSavedState$1@41959308, 84=android.view.AbsSavedState$1@41959308, 85=android.view.AbsSavedState$1@41959308, 86=android.view.AbsSavedState$1@41959308, 87=android.view.AbsSavedState$1@41959308, 88=android.view.AbsSavedState$1@41959308, 89=android.view.AbsSavedState$1@41959308, 90=android.view.AbsSavedState$1@41959308, 91=android.view.AbsSavedState$1@41959308, 92=android.view.AbsSavedState$1@41959308, 93=android.view.AbsSavedState$1@41959308, 94=android.view.AbsSavedState$1@41959308, 95=android.view.AbsSavedState$1@41959308, 96=android.view.AbsSavedState$1@41959308, 97=android.view.AbsSavedState$1@41959308, 98=android.view.AbsSavedState$1@41959308, 99=android.view.AbsSavedState$1@41959308, 100=android.view.AbsSavedState$1@41959308, {color:red}101=AbsListView.SavedState{44f8f800 selectedId=-9223372036854775808 firstId=-1 viewTop=0 position=0 height=540 filter=null checkState=null}, {color}102=android.view.AbsSavedState$1@41959308, 103=android.view.AbsSavedState$1@41959308, 104=android.view.AbsSaved {quote} I patched the SDK, change the id to a random big number, it would not crash now, but it is not a good solution, pls. handle it.

Comments

  1. Shuo Liang 2014-07-21

    Hi, Would you please us a test case for this problem, that will be really helpful. Thanks. Regards, Shuo
  2. Minglei Chen 2014-07-28

    This can be easily reproduced like this: build an application with many text views, at least 101. Add one table view. Now to cause the state restore, move the application to the back, enter system settings -> display -> font size, and change the size. Open the task list and select your app to bring it to front. The font size change will cause view state recalculation which will crash the app.
  3. Minglei Chen 2014-07-28

  4. Shuo Liang 2014-07-31

JSON Source