Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Another java.lang.IllegalArgumentException: parameter must be a descendant of this view

Users are getting the following exception in my app on certain phones. I tried reproducing the error myself but couldn't . I searched through stack overflow for similar problems and tried their solutions but none seem to be working.

Here are the answers I already tried:

  1. Preventing/catching "IllegalArgumentException: parameter must be a descendant of this view" error
  2. java.lang.IllegalArgumentException: parameter must be a descendant of this view Error
  3. Setting the following attribute: android:windowSoftInputMode="stateHidden|adjustPan"

I have an edittext but it's outside of the expandablelistview.

I am trying to find an explanation on why this is happening and what might cause it to happen. I apologize but I can't post any code.

java.lang.IllegalArgumentException: parameter must be a descendant of this view at android.view.ViewGroup.offsetRectBetweenParentAndChild(ViewGroup.java:4568) at android.view.ViewGroup.offsetDescendantRectToMyCoords(ViewGroup.java:4505) at android.view.ViewGroup$ViewLocationHolder.init(ViewGroup.java:6743) at android.view.ViewGroup$ViewLocationHolder.obtain(ViewGroup.java:6680) at android.view.ViewGroup$ChildListForAccessibility.init(ViewGroup.java:6638) at android.view.ViewGroup$ChildListForAccessibility.obtain(ViewGroup.java:6606) at android.view.ViewGroup.addChildrenForAccessibility(ViewGroup.java:1697) at android.view.ViewGroup.onInitializeAccessibilityNodeInfoInternal(ViewGroup.java:2525) at android.view.View.onInitializeAccessibilityNodeInfo(View.java:5213) at android.widget.AdapterView.onInitializeAccessibilityNodeInfo(AdapterView.java:946) at android.widget.AbsListView.onInitializeAccessibilityNodeInfo(AbsListView.java:1449) at android.widget.ListView.onInitializeAccessibilityNodeInfo(ListView.java:3781) at android.widget.ExpandableListView.onInitializeAccessibilityNodeInfo(ExpandableListView.java:1348) at android.view.View.createAccessibilityNodeInfoInternal(View.java:5174) at android.view.View.createAccessibilityNodeInfo(View.java:5161) at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:811) at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:834) at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:834) at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchAccessibilityNodeInfos(AccessibilityInteractionController.java:720) at android.view.AccessibilityInteractionController.findAccessibilityNodeInfoByAccessibilityIdUiThread(AccessibilityInteractionController.java:147) at android.view.AccessibilityInteractionController.access$300(AccessibilityInteractionController.java:49) at android.view.AccessibilityInteractionController$PrivateHandler.handleMessage(AccessibilityInteractionController.java:971) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5097) at java.lang.reflect.Method.invokeNative(Method.java) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) at dalvik.system.NativeStart.main(NativeStart.java)

like image 878
kyrax Avatar asked Jun 02 '15 00:06

kyrax


1 Answers

The problem was caused by adding a wrongly inflated header to two different listviews.

I inflated a view using listViewA as the parent and adding it to listViewB also. As such:

RelativeLayout listViewHeader = (RelativeLayout) inflater.inflate(R.layout.listviewheader, listViewA, false);

// Set some views

listViewA.addHeaderView(listViewHeader);
listViewB.addHeaderView(listViewHeader);

I fixed it by changing the above to the following:

RelativeLayout listViewHeaderA = (RelativeLayout) inflater.inflate(R.layout.listviewheader, listViewA, false);
RelativeLayout listViewHeaderB = (RelativeLayout) inflater.inflate(R.layout.listviewheader, listViewB, false);

listViewA.addHeaderView(listViewHeaderA);
listViewB.addHeaderView(listViewHeaderB);

As for reproducing the crash, the problem happened when Google Talk Back is turned on. Here is my take on the situation: Google Talk Back does text to speech on views that are in focus (either by touch or auto-focused). When it enters a screen with multiple views requesting focus, it reads the views according to a hierarchy/order.

If you have a layout (parent) with three views (children), Google Talk Back checks how the views are arranged and then reads them accordingly. For example, in a layout with three textview lined up horizontally, Google Talk Back may read the left textview first, then the middle one, then the one on the right.

In my case, I was inflating a header view with listViewA as the parent and adding that view to both listViewA and listViewB. When listViewBgains focus and Google Talk Back tries to interpret its children, it sees the header view is not a child of the list and throws the exception. This also happens if I inflate the header view with no parents (null).

like image 182
kyrax Avatar answered Sep 21 '22 16:09

kyrax