With app TalkBack active, I receive the exception:
java.lang.IllegalArgumentException: Comparison method violates its general contract!
The problem is I'm not using comparision method on my code.
Follow the complete exception:
java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.ComparableTimSort.mergeLo(ComparableTimSort.java:710)
at java.util.ComparableTimSort.mergeAt(ComparableTimSort.java:447)
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:6635)
at android.view.ViewGroup$ChildListForAccessibility.obtain(ViewGroup.java:6600)
at android.view.ViewGroup.addChildrenForAccessibility(ViewGroup.java:1703)
at android.view.ViewGroup.onInitializeAccessibilityNodeInfoInternal(ViewGroup.java:2529)
at android.view.View.onInitializeAccessibilityNodeInfo(View.java:5225)
at android.widget.AdapterView.onInitializeAccessibilityNodeInfo(AdapterView.java:937)
at android.widget.AbsListView.onInitializeAccessibilityNodeInfo(AbsListView.java:1494)
at android.widget.GridView.onInitializeAccessibilityNodeInfo(GridView.java:2263)
at android.view.View.createAccessibilityNodeInfoInternal(View.java:5186)
at android.view.View.createAccessibilityNodeInfo(View.java:5173)
at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:811)
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:149)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)
Why I've this exception only with TalkBack active? This exception appear after that gridview is loaded (on display the gridview is loaded correctly)
Thanks a lot
EDIT:
I've found that the problem is on this code line:
public class GridLayoutAdapter extends BaseAdapter
{
#Override
public View getView(int position, View view, ViewGroup parent) {
view.setLayoutParams(new GridView.LayoutParams(60, 60));
}
How to resolve the problem? I don't know why I've a Comparison method violates
(if I try to comment the line it works without crash)
Related
Crash occurs on Samsung devices (J7 and S7) running Android 7.0.
I've built a tiny test app and can reproduce the crash. Single Activity that extends Activity (not AppCompatActivity), simple layout containing a single EditText with inputType="text". Target SDK is 8.
When positioning the cursor in the EditText and typing, words are suggested and words are underlined. Click on some of the underlined words or complete editing in the EditText and then return to the EditText. After entering some data and clicking around inside the EditText, the app will crash with this stacktrace:
06-01 18:56:37.990 10339-10339/sharpmind.de.samsungtest W/ResourceType: No package identifier when getting value for resource number 0x00000000
06-01 18:56:37.991 10339-10339/sharpmind.de.samsungtest D/AndroidRuntime: Shutting down VM
06-01 18:56:37.992 10339-10339/sharpmind.de.samsungtest E/AndroidRuntime: FATAL EXCEPTION: main
Process: sharpmind.de.samsungtest, PID: 10339
android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:202)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2970)
at android.content.res.Resources.getLayout(Resources.java:1986)
at android.view.LayoutInflater.inflate(LayoutInflater.java:425)
at android.view.LayoutInflater.inflate(LayoutInflater.java:378)
at android.widget.Editor$SuggestionsPopupWindow.initContentView(Editor.java:3704)
at android.widget.Editor$PinnedPopupWindow.<init>(Editor.java:3395)
at android.widget.Editor$SuggestionsPopupWindow.<init>(Editor.java:3683)
at android.widget.Editor.replace(Editor.java:432)
at android.widget.Editor$3.run(Editor.java:2359)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
With target SDK set to 14, the crash does not occur.
If I disable the autocorrect and word suggestions (which isn't that easy to do on a Samsung device), the crash also does not occur. But this makes my users really really angry, so it isn't a viable solution.
Activity:
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Layout:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="#+id/edittext"
android:layout_width="match_parent"
android:minHeight="200dp"
android:inputType="text"
android:layout_height="wrap_content"/>
</RelativeLayout>
I tried to search for this problem but this error doesn't look to be the same as this error (my google play version is newer and notice that the error is at a different line of WebViewClassic, so might be different error or the same in a newer version) but I have received the exactly same error exception from webview
java.lang.NullPointerException
at android.webkit.WebViewClassic$WebViewInputConnection.setNewText(WebViewClassic.java:583)
at android.webkit.WebViewClassic$WebViewInputConnection.setComposingText(WebViewClassic.java:323)
at android.webkit.WebViewClassic$WebViewInputConnection.commitText(WebViewClassic.java:339)
at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:279)
at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:77)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:5297)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
However I am not using any webview class directly. However, this problem might be related to AdView, but I don't understand how. My code is the following:
#Override
public void onPause() {
//TODO: these lines are created because onPuase of Adview doesn't work
if ( adView != null ) {
adView.pause();
adView.destroy();
adView = null;
Log.i(ApplicationData.APP_TAG, TAG + ": OnPause, pausing the Adview");
}
super.onPause();
}
The error appears after the Log.i line, I would have expected this error to appear when AdView was called but not after. Is possible that this error is coming from a threaded action? Any idea how to avoid the problem?
As the example in https://developer.android.com/reference/com/google/android/gms/ads/AdView.html and the document for AdView.destroy(), you should only call adView.pause() in onPause(), and call adView.destroy() later in onDestroy().
The stack dump looks like another thread is accessing the destroyed AdView instance.
I have a DialogFragment which I am showing when a button is clicked. I have the following code in the onClick method of the button:
InfoTextDialog infoDialog = new InfoTextDialog(conditions[counter], information[counter]);
infoDialog.show(getFragmentManager(), null);
However, I sometime get the following exception:
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
This does not occur all the time, but it happens quite frequently. Can someone please explain to me what is causing this exception to be thrown, and how to solve this issue.
EDIT 1: Here is the stack trace:
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1318)
at android.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1329)
at android.app.BackStackRecord.commitInternal(BackStackRecord.java:607)
at android.app.BackStackRecord.commit(BackStackRecord.java:586)
at android.app.DialogFragment.show(DialogFragment.java:230)
at <...>.MyActivity$1.onClick(MyActivity.java:73)
at android.view.View.performClick(View.java:4235)
at android.view.View$PerformClick.run(View.java:17484)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:5299)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
at dalvik.system.NativeStart.main(Native Method)
hard to say without knowing more about your app - but this should help:
if (!getActivity().isFinishing()) {
InfoTextDialog infoDialog = new InfoTextDialog(conditions[counter], information[counter]);
infoDialog.show(getFragmentManager(), null);
}
I've been working on an existing codebase for a while and from browsing our crash log service I've noticed an exception that happens pretty frequently, I am not able to reproduce this issue, nor do I have the context for the scenario to try and dig in, as this is a pretty big project it has become increasingly hard to find out the cause of this exception.
I have been searching online for similar issues and couldn't find any useful information.
If anyone is familiar with this issue, your help would be greatly appreciated.
Stacktrace is as follows:
java.lang.NullPointerException
at android.animation.PropertyValuesHolder.setupSetterAndGetter(PropertyValuesHolder.java:505)
at android.animation.ObjectAnimator.initAnimation(ObjectAnimator.java:487)
at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:517)
at android.animation.ValueAnimator.start(ValueAnimator.java:936)
at android.animation.ValueAnimator.start(ValueAnimator.java:946)
at android.animation.ObjectAnimator.start(ObjectAnimator.java:465)
at android.animation.AnimatorSet$1.onAnimationEnd(AnimatorSet.java:579)
at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1056)
at android.animation.ValueAnimator.access$400(ValueAnimator.java:50)
at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:644)
at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:660)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:543)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5105)
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:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
at dalvik.system.NativeStart.main(NativeStart.java)
Cheers.
The issue turned out to be an animation being invoked from a Handler using postDelayed(), which eventually resulted in attempting to animate a null View reference, since it wasn't cleared properly according to it's host lifecycle events.
maybe you tagret is null, print log with animatorSet.getTarget() to see
I also get this stack trace when I use :
ObjectAnimator animator = ObjectAnimator.ofFloat(this, "scale", 1);
....
animator.start()
run in android 4.0.X, but it's ok for higher version, you can also refer this guy's commit, though I don't how to fix, however this is the root cause definitely.
I went through this exception now and find out that I was getting the instance of the View with animation from getActivity().findViewById. While being in a fragment I had to instantiate it from the rootview inflated containing the view.
I basically moved the view from the Activity to the Fragment layout, but didn't change the code.
So the rootview.findViewById resolved my problem.
My stacktrace:
java.lang.NullPointerException
at android.animation.PropertyValuesHolder.setupSetterAndGetter(PropertyValuesHolder.java:505)
at android.animation.ObjectAnimator.initAnimation(ObjectAnimator.java:392)
at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:495)
at android.animation.ValueAnimator.start(ValueAnimator.java:913)
at android.animation.ValueAnimator.start(ValueAnimator.java:923)
at android.animation.ObjectAnimator.start(ObjectAnimator.java:370)
at eu.davidea.passwordcloud.ui.ItemDetailFragment$3.onClick(ItemDetailFragment.java:162)
at android.view.View.performClick(View.java:4084)
at android.view.View$PerformClick.run(View.java:16966)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Trust me, I found the solution of this crash issue on 4.0.x devices.
The problem is when you use ObjectAnimator without 'start' and 'end' value, the api on 4.0.x devices can't find the 'start' value to implement.
For example, this will lead to crash on 4.0.x devices
int endRadiusValue = 10;
ObjectAnimator
.ofFloat(roundedGradientDrawable, "cornerRadius", endRadiusValue)
.setDuration(200)
.start();
And this code work perfect on all api level devices
int startRadiusValue = 0;
int endRadiusValue = 10;
ObjectAnimator
.ofFloat(roundedGradientDrawable, "cornerRadius", startRadiusValue, endRadiusValue)
.setDuration(200)
.start();
The reason is the target view is null. ObjectAnimator ofFloat(Object target, ...).
This crash will only throw in 4x device.
There is no crash in another device
I solve the problem by adding the animation to a animationSet just like this:
The main Activity in my Android app has a Gallery widget that loads XML layouts (containing TextViews and Images) through an efficient ImageAdapter. For the most part this works fine and I haven't had any problems on any of my devices or the emulator, but I have seen the following error in my logs. It looks like this is affecting less than 1% of users, but I'd like to know what's causing it, how to resolve it, or at least "catch" it and resolve gracefully. Any ideas?
java.lang.NullPointerException at
android.widget.Gallery.setUpChild(Gallery.java:772) at android.widget.Gallery.makeAndAddView(Gallery.java:751) at android.widget.Gallery.fillToGalleryLeft(Gallery.java:667) at android.widget.Gallery.trackMotionScroll(Gallery.java:378) at android.widget.Gallery$FlingRunnable.run(Gallery.java:1369) at android.os.Handler.handleCallback(Handler.java:587) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3695) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method)
I get this problem several days ago, please check your own gallery's adpater check its getView() methods,see if you return null in some if-cases,just replace return null with new View(context) (or other view but null) will simply solve this problem.Good luck