I got the following crash report in the android market place. While testing I haven't found any crash and my app works fine. Once I published my app I got the following crash report which I have shown below.
But I am not able to find where the crash occurs, I checked in some stack overflow question and there in some cases I got that use of setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); make cause crash in some devices. Is it true because in my app in some activity I have used this line of code in order to change the input type of EditText from password-text / text-password?
Please help me to solve this out.
Stack Trace
java.lang.NullPointerException
at android.widget.TextView.onTouchEvent(TextView.java:7529)
at android.view.View.dispatchTouchEvent(View.java:3933)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:906)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:906)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:906)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:906)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:906)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:906)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1877)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1211)
at android.app.Activity.dispatchTouchEvent(Activity.java:2198)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1852)
at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2382)
at android.view.ViewRoot.handleMessage(ViewRoot.java:2010)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4385)
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:849)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
at dalvik.system.NativeStart.main(Native Method)
<EditText
android:id="#+id/txt_edit_passwrd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_passwrd_title"
android:background="#drawable/img_password_textbox"
android:cursorVisible="true"
android:layout_marginTop="195dp"
android:hint="#string/passwrd_hint_text"
android:inputType="textPassword"
android:maxLength="10"
android:padding="10dp"
android:textColor="#121212" >
</EditText>
NullPointerException in my own experience tends to mean it cannot find a reference object for instance the edit text your setting the input type for cannot be found, check your layout references and how you've declared the EditText itself.
First check , Have you mention Minimum_sdk_version in android-manifest?
if not then following may be the reason of crashing your application--
If you are using that functionality of android o.s that does not support on customer device.Say you are using Finger_Pointer(as MotionEvent.ACTION_POINTER_DOWN) which does not support before android 2.0.
Or you are using onBackPressed() which does not support for android 1.6.I just gave you hint you can check other issue like this if you have
Updated
For HTC device, TextView's property InputType.TYPE_CLASS_NUMBER lead to crash
Here is the same problem discussed you can refer to this also.
The Solution is not to use "setInputType" with a TextView. You don't need input type filtering for TextViews anyway since they are for displaying text only. Input type is only needed for EditText (and there it works). I had the same problem with Android versions below 4.2.
The disadvantage is, that applying input type "password" on a textview actually makes sense as it masks the password, which may be intended (it was in my case). But this causes random crashes when touching or scrolling over the textview.
Related
When I try to select text many times in the TextView, the application crashes with the error.
Does anyone know what could be the problem?
Error Stacktrace:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: *** PID: 11481
java.lang.IndexOutOfBoundsException: setSpan (-1 ... -1) starts before 0
at android.text.SpannableStringInternal.checkRange(SpannableStringInternal.java:442)
at android.text.SpannableStringInternal.setSpan(SpannableStringInternal.java:163)
at android.text.SpannableStringInternal.setSpan(SpannableStringInternal.java:152)
at android.text.SpannableString.setSpan(SpannableString.java:46)
at android.text.Selection.setSelection(Selection.java:76)
at android.widget.Editor$SelectionModifierCursorController.resetDragAcceleratorState(Editor.java:5790)
at android.widget.Editor$SelectionModifierCursorController.onTouchEvent(Editor.java:5627)
at android.widget.Editor.onTouchEvent(Editor.java:1416)
at android.widget.TextView.onTouchEvent(TextView.java:9922)
at android.view.View.dispatchTouchEvent(View.java:11843)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2981)
....
2019-07-28 16:00:53.369 11481-11481/? E/AndroidRuntime: at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4650)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4623)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:7222)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:7196)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:7157)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:7379)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:193)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:379)
at android.os.Looper.loop(Looper.java:144)
at android.app.ActivityThread.main(ActivityThread.java:7383)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:963)
Here is the markup for TextView:
<TextView
android:id="#+id/list_item_message_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_marginBottom="6dp"
android:gravity="center_vertical"
android:inputType="none"
android:linksClickable="true"
android:singleLine="false"
android:text="TextView"
android:lineSpacingExtra="3dp"
android:textIsSelectable="true"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
In the code I set the attribute: messageView.setMovementMethod (LinkMovementMethod.getInstance ());
I was able to reproduce only on android O and android N, in the following scenario:
Given a RecyclerView which presents a ViewHolder containing a TextView
That TextView as .setTextIsSelectable(true) and .setMovementMethod(LinkMovementMethod.getInstance())
Selecting a text from TextView and scrolling away from that particular view will cause crash. In particular, scrolling away while having presented that system overlay which offers "Copy", "Cut", "Paste", etc
So, my workaround (not a real solution but it will prevent crashes and it doesn't take users out of my app) was not allowing text selection on affected builds:
val selectable = when {
Build.VERSION.SDK_INT <= Build.VERSION_CODES.M -> true
Build.VERSION.SDK_INT >= Build.VERSION_CODES.P -> true
else -> false
}
textView.setTextIsSelectable(selectable)
textView.setMovementMethod(LinkMovementMethod.getInstance())
remove this
android:lineSpacingExtra="3dp"
Try to specify android:inputType="text". As well, you can add android:autoLink="all"
I think this is a problem in the Android Framework. Similar to the one described here:
java.lang.IndexOutOfBoundsException: getChars (7 ... 0) has end before start
Because and I have a similar error too. Thank you all.
i'm new to android studio and my app is crushing besuase line of code
songProgressBar.setOnSeekBarChangeListener(this);
posting a question here helped me to realize it is a typo with an id in my layout. Well, here is the code for my layout with songProgressBar as an id.
<SeekBar
android:id="#+id/songProgressBar"
android:layout_width="fill_parent"
android:layout_height="25dp"
android:layout_marginRight="15dp"
android:layout_marginLeft="15dp"
android:layout_above="#id/player_footer_bg"
android:thumb="#drawable/seek_handler"
android:progressDrawable="#drawable/seekbar_progress_blue"
android:paddingLeft="6dp"
android:paddingRight="6dp"/>
Now, i don't know what the typo is, and i don't know what i'm to do. the person who told me it is a typo said i should check whether the component is present in the layout when the activity is running. I've got no idea what I'm to do now. pls help.
There seems to be a null pointer exception.
21:39:10.999 1443-1443/? E/AndroidRuntime: Caused by: java.lang.NullPointerException 01-10 21:39:10.999 1443-1443/? E/AndroidRuntime: at com.example.passion.patrimusic.MainActivity.onCreate(MainActivity.java:86) 01-10 21:39:10.999
And from your above comment, its possible that songProgressBar is null.
If you are getting it from the layout, check if there's any typo in the Id and whether the component is present in the layout when the activity is running.
I just released an alarm app and it's been hell. It's breaking on certain devices when they try to open up the alarm list screen. I have no idea why it's breaking on some devices and not others. Every phone I've seen it tried on it works perfectly, but opening up the alarm list on some other devices blows it up. I'm really out of my depth for this kind of specific device compatibility issue.
The code at AlarmClock line 227 is this:
View changeSettings = findViewById(R.id.alarm_settings);
changeSettings.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
startActivity(new Intent(getApplicationContext(), SettingsActivity.class));
}
});
And it references this line of xml:
<Button
android:id="#+id/alarm_settings"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0.0dip" android:layout_height="fill_parent"
android:text="#string/menu_settings"
android:layout_weight="1.0" />
This links to a settings activity I borrowed the source of from an adapted version of the android stock alarm, but it uses addPreferencesFromResource which is allegedly deprecated. Is that what's causing this problem?
This is the stack trace from the user's device:
Nexus 7
Touched setup alarm button and then it crashed
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nathantempelman.GoodMorningAlarmFree/com.nathantempelman.alarmclockfree.AlarmClock}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2185)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2210)
at android.app.ActivityThread.access$600(ActivityThread.java:142)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1208)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4931)
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:791)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.nathantempelman.alarmclockfree.AlarmClock.updateLayout(AlarmClock.java:227)
at com.nathantempelman.alarmclockfree.AlarmClock.onCreate(AlarmClock.java:210)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2139)
... 11 more
Any help would be splendiferous. I know that it's happened on someone else's tablet as well, not sure if it's a tablet issue.
The app is here if anyone wants to give it a test: https://play.google.com/store/apps/details?id=com.nathantempelman.GoodMorningAlarmFree
you have a NullPointerException in your AlarmClock class in updateLayout method in line 227 :)
Caused by: java.lang.NullPointerException
at com.nathantempelman.alarmclockfree.AlarmClock.updateLayout(AlarmClock.java:227)
at com.nathantempelman.alarmclockfree.AlarmClock.onCreate(AlarmClock.java:210)
i would check that code first.
as you didn't post any code, i cant help more at the moment :)
Just in case someone else stumbles across this, the problem in the end was that there was a separate layout file for tablets which I hadn't seen in the source codebase I borrowed for a part of my application. I had obviously added a bunch of functionality, but hadn't updated the tablet layout. The buttons to access the things I had added weren't in the tablet layout file. Ergo, null pointer exception only when a tablet device loaded the tablet layout file and searched for non existent objects in the display. When I deleted that file, everything worked perfectly.
I know, hurp and or durp. But maybe someone has the same problem and might want to check for this.
I have app with ActionBarScherlock and I use ACRA. I receive crash reports from some users with following error:
"java.lang.RuntimeException: Binary XML file line #20: You must supply a layout_height attribute.
at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:491)
at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:3602)
at android.view.ViewGroup$LayoutParams.<init>(ViewGroup.java:3554)
at android.widget.AbsListView$LayoutParams.<init>(AbsListView.java:4322)
at android.widget.AbsListView.generateLayoutParams(AbsListView.java:4116)
at android.widget.AbsListView.generateLayoutParams(AbsListView.java:74)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:332)
at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
at android.webkit.WebTextView$AutoCompleteAdapter.getView(WebTextView.java:650)
at android.widget.AbsListView.obtainView(AbsListView.java:1430)
at android.widget.AutoCompleteTextView$DropDownListView.obtainView(AutoCompleteTextView.java:1548)
at android.widget.ListView.measureHeightOfChildren(ListView.java:1216)
at android.widget.AutoCompleteTextView.buildDropDown(AutoCompleteTextView.java:1376)
at android.widget.AutoCompleteTextView.showDropDown(AutoCompleteTextView.java:1140)
at android.widget.AutoCompleteTextView.updateDropDownForFilter(AutoCompleteTextView.java:1022)
at android.widget.AutoCompleteTextView.onFilterComplete(AutoCompleteTextView.java:1005)
at android.widget.Filter$ResultsHandler.handleMessage(Filter.java:285)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3717)
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:864)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
at dalvik.system.NativeStart.main(Native Method)"
Of course I've tried to google it and found that it is most likely caused by ActionBarScherlock (and I noticed that every user who encountered with this error uses android 2.3.*) but haven't found a solution.
It's a bit disconcerting that I can't reproduce this error on my own 2.3.* device...
So, what causes this error?
In my case this was due to a problem with ActionBarsherlock.
In my Android manifest I had android:theme="#style/AppTheme"
then when you go to styles, i saw my AppTheme's parent was "AppBaseTheme". This was the problem!
<style name="AppTheme" parent="AppBaseTheme">
I changed this to
<style name="AppTheme" parent="Theme.Sherlock">
And my problem was solved.
One of our #1 crashes came from this issue, especially on ZTE devices. While the actionbar worked on most screens, we were getting this crash when users interacted with a Webview Edittext/InputBox. The crash happened as a result of autocomplete on the Webview. Disabling autocomplete seemed to eliminate the crashes. Why autocomplete should have anything to do with the Actionbar is still a mystery.
Here we disable the autocomplete just for ZTE devices. We may expand the list later if we have problems on other devices.
public static boolean disableWebViewAutoCompleteForDevicesThatCrash(WebView webView)
{
// We may add some other bizarre devices to this list if the ZTE fix works well.
if ("ZTE".equals(Build.MANUFACTURER))
{
webView.getSettings().setSaveFormData(false);
webView.clearFormData();
return true;
}
else
{
return false;
}
}
The layout_height in this instance is defined as ?attr/actionBarSize which is a theme attribute with a value of #dimen/action_bar_height that is defined in three places: values/, values-land/, and values-sw600dp/.
This is usually cased by OEMs who've tinkered with the resource system causing some aspect of this chain to not load correctly. There's nothing we can really do, as far as I'm aware.
I had same problem and solve it by change in AndroidManifest.xml. You have to set theme of particular Activity or complete application to Theme.Sherlock.Light (I think you can specify only Theme.Sherlock).
In code it will be:
<application
...
android:theme="#style/Theme.Sherlock.Light">
or
<activity
...
android:theme="#style/Theme.Sherlock.Light">
I'm getting this wild exception from Android market report. It happens about 4-6 times a week(we have over 100k user base). I attached the code snippet under the stack. I couldn't even find the Text.java source code.
java.lang.ArrayIndexOutOfBoundsException: result:3
at android.graphics.Text.setPaint(Native Method)
at android.graphics.Text.setPaint(Text.java:211)
at android.text.Layout.each(Layout.java:350)
at android.text.Layout.decorateText(Layout.java:312)
at android.text.Layout.reflow(Layout.java:410)
at android.text.Layout.reflowFull(Layout.java:369)
at android.text.StaticLayout.<init>(StaticLayout.java:114)
at android.text.StaticLayout.<init>(StaticLayout.java:67)
at android.text.StaticLayout.<init>(StaticLayout.java:51)
at android.widget.TextView.makeNewLayout(TextView.java:5315)
at android.widget.TextView.checkForRelayout(TextView.java:5765)
at android.widget.TextView.setText(TextView.java:2781)
at android.widget.TextView.setText(TextView.java:2649)
at android.widget.TextView.setText(TextView.java:2624)
at com.soakmein.MessageListView$StreamAdapter.getView(MessageListView.java:1042)
at android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java:220)
at android.widget.AbsListView.obtainView(AbsListView.java:1498)
at android.widget.ListView.makeAndAddView(ListView.java:1749)
at android.widget.ListView.fillUp(ListView.java:704)
at android.widget.ListView.fillGap(ListView.java:650)
at android.widget.AbsListView.trackMotionScroll(AbsListView.java:3521)
at android.widget.AbsListView.onTouchEvent(AbsListView.java:2339)
at android.widget.ListView.onTouchEvent(ListView.java:3447)
at android.view.View.dispatchTouchEvent(View.java:3952)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:995)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1034)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1034)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1034)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1034)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1711)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1145)
at android.app.Activity.dispatchTouchEvent(Activity.java:2096)
this is the line where the excpetion was fired:
messageText.setText(Html.fromHtml(text));
Maybe you can post the source code.
Other than that, I would suggest you go through the stack until you find the line where the out of bounds error occurs.
It is likely that you are using a variable to keep track of the index of the array and that variable is not bounded by a rule with the same bounds as your array.