I have a very strange crash in application.
Stacktrace:
java.lang.IndexOutOfBoundsException: charAt: -1 < 0
at android.text.SpannableStringBuilder.charAt(SpannableStringBuilder.java:112)
at android.text.Selection.setSelection(Selection.java:84)
at android.text.Selection.setSelection(Selection.java:127)
at android.widget.Editor$InsertionHandleView.updateSelection(Editor.java:4971)
at android.widget.Editor$HandleView.positionAtCursorOffset(Editor.java:4647)
at android.widget.Editor$HandleView.updatePosition(Editor.java:4675)
at android.widget.Editor$PositionListener.onPreDraw(Editor.java:2714)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:711)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2097)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1179)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4859)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
at android.view.Choreographer.doCallbacks(Choreographer.java:562)
at android.view.Choreographer.doFrame(Choreographer.java:532)
at android.view.Choreographer$FrameHandler.handleMessage(Choreographer.java:664)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5328)
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:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
I got the stack trace without any links on my application's packages (classes/methods).
Has anyone encountered this problem? Thx.
EDIT
Can you see, the stack trace has not any links on my application's packages/classes, but app anyway crashed.
UPD
I use Selection.setSelection. I don't use SpannableStringBuilder.
#Override
public void afterTextChanged(Editable s) {
if (!s.toString().isEmpty()) {
Selection.setSelection(s, s.length());
}
}
This seems to be an OS bug which require a combination of a certain OS version(e.g. 4.1.2) and a certain device(e.g. Galaxy S3 I9300). This is not your problem. Unfortunately I don't know how to get around this either.
I'm curious how you ran into this issue. Based on the callstack, my guess is you tap on a textview and tried to paste text from clipboard.
Read the first line... it says java.lang.IndexOutOfBoundsException: charAt: -1 < 0. The problem is your string does not have the character you are searching for. Post the code. Then we will see what's wrong...
Related
View.startDrag throws NPE and this is happening to me for Android API 15 but not API 22.
This issue is very easy to reproduce. Open Android Studio, create a template project with one blank activity using API 15. Adding the following logic to the floating action button:
fab.setOnLongClickListener(
new View.OnLongClickListener() {
#Override
public boolean onLongClick(View v) {
v.startDrag(ClipData.newPlainText("", ""), new View.DragShadowBuilder(v), null, 0);
return true;
}
}
);
The stacktrace for the error is the following:
E/View: Unable to initiate drag
java.lang.NullPointerException
at android.view.Surface.lockCanvas(Surface.java:77)
at android.view.View.startDrag(View.java:13869)
at test.dragdroptest.MainActivity$2.onLongClick(MainActivity.java:59)
at android.view.View.performLongClick(View.java:3827)
at android.view.View$CheckForLongPress.run(View.java:14571)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
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:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Not sure what I did wrong here. I have been fighting this issue for two days and there is not much resource online about this. I cannot believe no one else had ran into the same issue...
Apparently, it only happens on the device I used for testing but not from emulator with the same API level. I guess there is no way I can get away from this issue :(
I'm getting daily crash reports from Google Play. I'm running out of ideas and wondering if there is any tutorials or something on how to find and fix bugs from google plays stack report.
I have done the following
Bought one of the devices it is crashing on, Galaxy tab. Tried to crash it, could not get it to crash. Tied to have a lot of apps running in background still did not crash.
put try catch around all my code where the catch would bring up a generic memory low warning message (ie this really slowed down the app).
Checked all my return values.
From the stack report, I'm assuming it is crashing somewhere in onTouchEvent methed in my cPuzzleView class.
Any help would be GREAT
stack
java.lang.NullPointerException
at com.fairhvaenapps.toddpuzzlefree.cPuzzleView.onTouchEvent(cPuzzleView.java:653)
at android.view.View.dispatchTouchEvent(View.java:7380)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2210)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1953)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2210)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1953)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2210)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1953)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2111)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1559)
at android.app.Activity.dispatchTouchEvent(Activity.java:2478)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2059)
at android.view.View.dispatchPointerEvent(View.java:7560)
at android.view.ViewRootImpl$1.doDispatch(ViewRootImpl.java:338)
at com.lge.view.TouchEventFilter.dispatchFilteredTouchEvent(TouchEventFilter.java:131)
at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3333)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3255)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4418)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4397)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4506)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:179)
at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:171)
at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:4468)
at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:4525)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
at android.view.Choreographer.doCallbacks(Choreographer.java:562)
at android.view.Choreographer.doFrame(Choreographer.java:530)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5223)
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:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:564)
at dalvik.system.NativeStart.main(Native Method)
I have the following Android exception. It is reported by Bugsense and I cannot find out where it comes from as there is no reference to any class of my app.
java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
at java.util.ArrayList.get(ArrayList.java:304)
at android.widget.HeaderViewListAdapter.isEnabled(HeaderViewListAdapter.java:164)
at android.widget.AbsListView$ListItemAccessibilityDelegate.onInitializeAccessibilityNodeInfo(AbsListView.java:2512)
at android.view.View.onInitializeAccessibilityNodeInfo(View.java:4849)
at android.widget.LinearLayout.onInitializeAccessibilityNodeInfo(LinearLayout.java:1768)
at android.view.View.createAccessibilityNodeInfo(View.java:4812)
at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:825)
at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:848)
at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:848)
at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:848)
at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:848)
at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchAccessibilityNodeInfos(AccessibilityInteractionController.java:734)
at android.view.AccessibilityInteractionController.findAccessibilityNodeInfoByAccessibilityIdUiThread(AccessibilityInteractionController.java:205)
at android.view.AccessibilityInteractionController.access$400(AccessibilityInteractionController.java:49)
at android.view.AccessibilityInteractionController$PrivateHandler.handleMessage(AccessibilityInteractionController.java:985)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4867)
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:1007)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
at dalvik.system.NativeStart.main(Native Method)
I do suspect it has something to do with updating a widget. Any ideas on how to trace?
Got similar Nullpointer with a Google map view.
try and turn off any accessibility options enabled on your phone?
And there is a another accessibility bug reported on the Android Issues tracker here
It looks like there is no easy way to turn of accessibility from code, except for overriding the addChildrenForAccessibility method in a custom view. (see above link)
On Google Play developer console I sometimes get crash reports that I don't understand at all. There is noting from my app code in the stack trace reported. Could anyone shed some light e.g. on this one?
java.lang.NullPointerException
at android.os.Parcel.readException(Parcel.java:1338)
at android.os.Parcel.readException(Parcel.java:1286)
at android.speech.tts.ITextToSpeechService$Stub$Proxy.setCallback(ITextToSpeechService.java:573)
at android.speech.tts.TextToSpeech$Connection.onServiceConnected(TextToSpeech.java:1278)
at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1125)
at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1142)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:4945)
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:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
It's clearly in some Text to Speech package, but how am I, the app author, resposible for this one? I do initialize TTS and my app is reading text aloud, but how can I fix such error?
Greg
here is your errors
ITextToSpeechService$Stub$Proxy.setCallback(ITextToSpeechService.java:573)
it's clearly !
I have a null pointer exception somewhere, but I am not sure where. All I have is this error:
java.lang.NullPointerException
at android.widget.ArrayAdapter.getCount(ArrayAdapter.java:330)
at android.widget.AdapterView.checkFocus(AdapterView.java:700)
at android.widget.AdapterView$AdapterDataSetObserver.onInvalidated(AdapterView.java:823)
at android.widget.AbsListView$AdapterDataSetObserver.onInvalidated(AbsListView.java:5738)
at android.database.DataSetObservable.notifyInvalidated(DataSetObservable.java:47)
at android.widget.BaseAdapter.notifyDataSetInvalidated(BaseAdapter.java:59)
at android.widget.ArrayAdapter$ArrayFilter.publishResults(ArrayAdapter.java:513)
at android.widget.Filter$ResultsHandler.handleMessage(Filter.java:282)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4697)
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:787)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
at dalvik.system.NativeStart.main(Native Method)
Would anyone have any ideas for how to debug this? I have not been able to reproduce it. It just sometimes happens and shows up in my crash logs.
Thanks!
Here's the code for ArrayAdapter: https://github.com/android/platform_frameworks_base/blob/master/core/java/android/widget/ArrayAdapter.java.
Assuming this is the right version, an NPE on line 330 would be caused if the adapter's dataset (i.e. the backing list or array) is null.
Hope that helps.