CollapsingToolbarLayout.drawChild crashed randomly for some users - android

I am using collapsing toolbar in my application.It is crashing randomly for some users not every time. Below is the crash log-
Fatal Exception: java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap#1e64241
at android.graphics.BaseCanvas.throwIfCannotDraw(BaseCanvas.java:87)
at android.graphics.RecordingCanvas.throwIfCannotDraw(RecordingCanvas.java:263)
at android.graphics.BaseRecordingCanvas.drawBitmap(BaseRecordingCanvas.java:98)
at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:560)
at android.widget.ImageView.onDraw(ImageView.java:1446)
at android.view.View.draw(View.java:24395)
at android.view.View.updateDisplayListIfDirty(View.java:23256)
at android.view.View.draw(View.java:24125)
at android.view.ViewGroup.drawChild(ViewGroup.java:4748)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4505)
at android.view.View.updateDisplayListIfDirty(View.java:23242)
at android.view.View.draw(View.java:24125)
at android.view.ViewGroup.drawChild(ViewGroup.java:4748)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4505)
at android.view.View.draw(View.java:24398)
at android.view.View.updateDisplayListIfDirty(View.java:23256)
at android.view.View.draw(View.java:24125)
at android.view.ViewGroup.drawChild(ViewGroup.java:4748)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4505)
at android.view.View.updateDisplayListIfDirty(View.java:23242)
at android.view.View.draw(View.java:24125)
at android.view.ViewGroup.drawChild(ViewGroup.java:4748)

Related

My App is Crashing while using google maps in my flutter application

Here is the error while crashing:-
Process: com.example.basic_setup, PID: 13613
java.lang.NullPointerException: Attempt to get length of null array
at java.nio.ByteBufferAsIntBuffer.put(ByteBufferAsIntBuffer.java:122)
at com.google.maps.api.android.lib6.gmm6.vector.gl.buffer.n.i(:com.google.android.gms.dynamite_mapsdynamite#223017097#22.30.17 (190400-0):2)
at com.google.maps.api.android.lib6.gmm6.vector.gl.buffer.n.d(:com.google.android.gms.dynamite_mapsdynamite#223017097#22.30.17 (190400-0):3)
at com.google.maps.api.android.lib6.gmm6.vector.gl.drawable.d.s(:com.google.android.gms.dynamite_mapsdynamite#223017097#22.30.17 (190400-0):2)
at com.google.maps.api.android.lib6.gmm6.vector.gl.drawable.ao.s(:com.google.android.gms.dynamite_mapsdynamite#223017097#22.30.17 (190400-0):12)
at com.google.maps.api.android.lib6.gmm6.vector.bz.s(:com.google.android.gms.dynamite_mapsdynamite#223017097#22.30.17 (190400-0):29)
at com.google.maps.api.android.lib6.gmm6.vector.bs.b(:com.google.android.gms.dynamite_mapsdynamite#223017097#22.30.17 (190400-0):151)
at com.google.maps.api.android.lib6.gmm6.vector.av.run(:com.google.android.gms.dynamite_mapsdynamite#223017097#22.30.17 (190400-0):48)
I am getting error while navigating fastly from another screen to map screen in bottom navigation bar.
this is the known issue in map v2:
https://issuetracker.google.com/issues/35829536
Use SupportMapFragment in xml file instead of mapview. eg :
<fragment
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
for more infmormation follow these links :
https://developers.google.com/android/reference/com/google/android/gms/maps/SupportMapFragment
https://developers.google.com/maps/documentation/android-api/map

Espresso can't click displayed view

Overnight my ui tests stopped working all of a sudden:
Line in barista clickOn(R.id.myView) throws:
com.schibsted.spain.barista.internal.failurehandler.BaristaException: Could not perform action single click on view with id: [...]
[...]
Caused by: androidx.test.espresso.NoMatchingViewException: No views in hierarchy found matching: (is displayed on the screen to the user and with id: [...]
Line in Espresso onView(withId(R.id.myView)).perform(scrollTo(), click()) throws:
androidx.test.espresso.PerformException: Error performing 'single click - At Coordinates: 53, 1723 and precision: 16, 16' on view 'Animations or transitions are enabled on the target device.
[...]
Caused by: java.util.NoSuchElementException: List is empty.
I don't understand why this happens. I can see the view on screen during the test and espresso gave me some coordinates.
Edit:
Since it's a TextView I also tried Baristas clickOn(context.getString(R.string.myText)) but it throws:
com.schibsted.spain.barista.internal.failurehandler.BaristaException: Could not perform action single click on view with text: is [...]
[...]
Caused by: androidx.test.espresso.NoMatchingViewException: No views in hierarchy found matching: (is displayed on the screen to the user and with text: is [...]
<TextView
android:id="#+id/myView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/myText"/>
The error is unrelated to Espresso or Barista.
java.util.NoSuchElementException: List is empty was thrown in the OnClickListener of the view.

Prevent app crash when cut operation in TextView

I put text-selectable TextView in Android layout with setTextIsSelectable(true) and the text is set by Html.fromHtml(sometexts).
It works good to allow user to copy text.
My JellyBean device gives small baloons with cut/copy/paste buttons on top of the selected text.
But when user accidently click cut icon left side of the copy menu, it crashes.
The log is given as below but there is no point to handle this exception in my application.
How to prevent app crash?
01-06 19:29:16.025 2048-2048/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.ClassCastException: android.text.SpannableString cannot be cast to android.text.Editable
at android.widget.TextView.deleteText_internal(TextView.java:8865)
at android.widget.TextView.onTextContextMenuItem(TextView.java:8315)
at android.widget.Editor$ActionPopupWindow.onClick(Editor.java:3556)
at android.view.View.performClick(View.java:4114)
at android.view.View$PerformClick.run(View.java:17097)
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:4885)
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:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)
I'm not sure and I can't test it right now but maybe try to put that in your TextView xml :
android:bufferType="spannable"
If it's still not working you can implement yourself your action for the selectable event.
Look at the answer of this question here :
Android- How can I show text selection on textview?

Android Gallery Widget Error: java.lang.NullPointerException at android.widget.Gallery.setUpChild

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

java.lang.OutOfMemoryError: bitmap size exceeds VM budget while Executing Android Expandable List

Based on the String in my activity iam executing expandable list (Am retrieving all child content from the raw folder(data.txt) ) but the problem was coming while setting adapter
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String s11="friendly-lovable";
temp=s11.split(delimeter);
for(i =0; i < temp.length ; i++)
System.out.println(temp[0]);
System.out.println(temp[1]);
System.out.println(temp.length);
DataGetting();//this method for adding items to expandable List.it is running successfully
DataGetting1();//calling all values from raw data.txt file for first word temp[0] .it is also executing successfully
childAdding();//calling all values from raw data.txt file for first word temp[1] .it is also executing successfully
elasricadapter=new MyExpandableListAdapter();
//up to this executing successfully .
setListAdapter(elasricadapter); //from this line am getting error in log cat .
error is:
ERROR/dalvikvm-heap(598): 355200-byte external allocation too large for this process.
ERROR/GraphicsJNI(598): VM won't let us allocate 355200 bytes
ERROR/AndroidRuntime(598): FATAL EXCEPTION: main
ERROR/AndroidRuntime(598): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gini/com.gini.Mainactivity}: android.view.InflateException: Binary XML file line #20: Error inflating class android.widget.ExpandableListView
ERROR/AndroidRuntime(598): Caused by: android.view.InflateException: Binary XML file line #20: Error inflating class android.widget.ExpandableListView
: ERROR/AndroidRuntime(598): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
ERROR/AndroidRuntime(598): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
ERROR/AndroidRuntime(598): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:450)
ERROR/AndroidRuntime(598): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:326)
So please help me any one AASP
T&R
Rajinikanth
You should also try to test your app directly on a real device (with all the debugging tools available with the emulator), because it's possible that the Out Of Memory exception does not appear. It was the case for one of my app. But still, it does not mean that it will never happen.
A bitmap is being processed at that stage.
This image is simply to big. There is no workaround but using a smaller image.
This question comes up very frequently and there are answers for it:
Have a look: https://stackoverflow.com/search?q=%5Bandroid%5D+OutOfMemoryError%3A+bitmap+size+exceeds+VM+budget

Categories

Resources