On my "Play Console" for android developers I've got recently 10 same crashes for one of my users with Android 10 (API 29) with OnePlus 6T phone.
The stack trace is:
java.lang.NullPointerException: at java.io.StringReader.<init> (StringReader.java:50) at android.text.HtmlToSpannedConverter.convert (Html.java:748) at android.text.Html.fromHtml (Html.java:243) at android.text.Html.fromHtml (Html.java:186) at com.rozmowkipraktyczne.PhrasesAdapter.getView (PhrasesAdapter.java:70) at android.widget.AbsListView.obtainView (AbsListView.java:2472) at android.widget.ListView.makeAndAddView (ListView.java:2078) at android.widget.ListView.fillDown (ListView.java:797) at android.widget.ListView.fillFromTop (ListView.java:859) at android.widget.ListView.layoutChildren (ListView.java:1849) at android.widget.AbsListView.onLayout (AbsListView.java:2269) at android.view.View.layout (View.java:22085) at android.view.ViewGroup.layout (ViewGroup.java:6290) at android.widget.LinearLayout.setChildFrame (LinearLayout.java:1829) at android.widget.LinearLayout.layoutVertical (LinearLayout.java:1673) at android.widget.LinearLayout.onLayout (LinearLayout.java:1582) at android.view.View.layout (View.java:22085) at android.view.ViewGroup.layout (ViewGroup.java:6290) at android.widget.FrameLayout.layoutChildren (FrameLayout.java:332) at android.widget.FrameLayout.onLayout (FrameLayout.java:270) at android.view.View.layout (View.java:22085) at android.view.ViewGroup.layout (ViewGroup.java:6290) at android.widget.FrameLayout.layoutChildren (FrameLayout.java:332) at android.widget.FrameLayout.onLayout (FrameLayout.java:270) at android.view.View.layout (View.java:22085) at android.view.ViewGroup.layout (ViewGroup.java:6290) at androidx.appcompat.widget.ActionBarOverlayLayout.onLayout (ActionBarOverlayLayout.java:55) at android.view.View.layout (View.java:22085) at android.view.ViewGroup.layout (ViewGroup.java:6290) at android.widget.FrameLayout.layoutChildren (FrameLayout.java:332) at android.widget.FrameLayout.onLayout (FrameLayout.java:270) at android.view.View.layout (View.java:22085) at android.view.ViewGroup.layout (ViewGroup.java:6290) at android.widget.LinearLayout.setChildFrame (LinearLayout.java:1829) at android.widget.LinearLayout.layoutVertical (LinearLayout.java:1673) at android.widget.LinearLayout.onLayout (LinearLayout.java:1582) at android.view.View.layout (View.java:22085) at android.view.ViewGroup.layout (ViewGroup.java:6290) at android.widget.FrameLayout.layoutChildren (FrameLayout.java:332) at android.widget.FrameLayout.onLayout (FrameLayout.java:270) at com.android.internal.policy.DecorView.onLayout (DecorView.java:786) at android.view.View.layout (View.java:22085) at android.view.ViewGroup.layout (ViewGroup.java:6290) at android.view.ViewRootImpl.performLayout (ViewRootImpl.java:3348) at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2819) at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1932) at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:8003) at android.view.Choreographer$CallbackRecord.run (Choreographer.java:1154) at android.view.Choreographer.doCallbacks (Choreographer.java:977) at android.view.Choreographer.doFrame (Choreographer.java:893) at android.view.Choreographer$FrameHandler.handleMessage (Choreographer.java:1082) at android.os.Handler.dispatchMessage (Handler.java:107) at android.os.Looper.loop (Looper.java:214) at android.app.ActivityThread.main (ActivityThread.java:7682) at java.lang.reflect.Method.invoke (Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:516) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:950)
According to stack trace above my problem sits in getView() method of the Adapter for ListView and caused by android.text.Html.fromHtml method.
But I cannot replicate this issue!! On my emulators with API 29 and API 30 app just works FINE!
For the sake of finding the truth I giving you also getView() method code:
@Overridepublic View getView(final int position, View convertView, ViewGroup parent) { // Get the phrase for this position final Phrase phrase = getItem(position); View item = convertView; PhrasesViewHolder holder = null; // Check if an existing view is being reused, otherwise inflate the view if (item == null) { item = LayoutInflater.from(getContext()).inflate(R.layout.list_item_phrases, parent, false); if(highlightingResource != 0) item.findViewById(R.id.ll_ua_transliterated).setBackgroundResource(highlightingResource); holder = new PhrasesViewHolder(item); item.setTag(holder); } else { holder = (PhrasesViewHolder) item.getTag(); } // Populate the phrase into found TextViews holder.tvPhrasePl.setText(phrase.getPhrasePl()); // !!!!!Check how to use depricated holder.tvPhraseUaTransliterated.setText(Html.fromHtml(phrase.getPhraseUaTransliterated())); holder.tvPhraseUa.setText(phrase.getPhraseUa()); if(areItemsPlaying[position]) holder.icPlayStop.setImageResource(R.drawable.ic_stop); else holder.icPlayStop.setImageResource(R.drawable.ic_play_pronunciation); //filled heart icon for favorites if needed if (isInFavorites(phrase.getChapter(), phrase.getPhraseNumber())) holder.heartFavorites.setImageResource(R.drawable.ic_heart_filled); else { holder.heartFavorites.setImageResource(R.drawable.ic_heart_empty); } //set listener on heart ic to add phrase to favorites or remove from there setListenerFavorites(holder, phrase); // Return the completed view to render on screen return item;}
And I've had this idea that method android.text.Html.fromHtml(oneArgument) is deprecated and maybe was removed, but by running on emulator API 29,30 it looks like this method is still there even though it is deprecated.
Guys, any Ideas what can cause the issue? And should i even worry about or leave it just like that..?
Thanks in advance!