Monday, 1 April 2019

java.lang.IllegalArgumentException: Comparison method violates its general contract?

I found many duplicate issues related to this title, but none of them were related to my issue since my issue cannot be traced through crashlytics. I keep receiving many different crashes regarding this title.

Check this example (it is happening only on android 4) :

enter image description here

Fatal Exception: java.lang.IllegalArgumentException: Comparison method violates its general contract!
       at java.util.ComparableTimSort.mergeHi(ComparableTimSort.java:831)
       at java.util.ComparableTimSort.mergeAt(ComparableTimSort.java:449)
       at java.util.ComparableTimSort.mergeCollapse(ComparableTimSort.java:372)
       at java.util.ComparableTimSort.sort(ComparableTimSort.java:178)
       at java.util.ComparableTimSort.sort(ComparableTimSort.java:142)
       at java.util.Arrays.sort(Arrays.java:1970)
       at java.util.Collections.sort(Collections.java:1864)
       at android.view.ViewGroup$ChildListForAccessibility.init(ViewGroup.java:6872)
       at android.view.ViewGroup$ChildListForAccessibility.obtain(ViewGroup.java:6837)
       at android.view.ViewGroup.dispatchPopulateAccessibilityEventInternal(ViewGroup.java:2706)
       at android.view.View.dispatchPopulateAccessibilityEvent(View.java:5217)
       at android.view.ViewGroup.dispatchPopulateAccessibilityEventInternal(ViewGroup.java:2712)
       at android.view.View.dispatchPopulateAccessibilityEvent(View.java:5217)
       at android.view.View.sendAccessibilityEventUncheckedInternal(View.java:5177)
       at android.view.View.sendAccessibilityEventUnchecked(View.java:5159)
       at android.view.View.sendAccessibilityEventInternal(View.java:5136)
       at android.view.View.sendAccessibilityEvent(View.java:5105)
       at android.view.View.performClick(View.java:4649)
       at android.view.View$PerformClick.run(View.java:19438)
       at android.os.Handler.handleCallback(Handler.java:733)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:146)
       at android.app.ActivityThread.main(ActivityThread.java:5602)
       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:1283)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
       at dalvik.system.NativeStart.main(NativeStart.java)

I found through research that it happens when comparing/sorting while missing out a certain condition. Meanwhile in my code, i do not use the compare or the sort method mentioned in the documentations/examples.

Any advise is highly appreciated.



from java.lang.IllegalArgumentException: Comparison method violates its general contract?

No comments:

Post a Comment