I get this stacktrace from the Market developer console every once in a while; I can't find any way to repro the error. It's happening while displaying a splashscreen ImageView as the app is first loading, but the stacktrace doesn't have any of my code. I don't even think my activity has even reached onCreate
, though it's hard to tell without a log.
Indeed, I never actually use a Bitmap anywhere in my code; my only reference to the image is in my layout.xml.
<ImageView android:id="@+id/splashScreen" android:layout_height="fill_parent" android:layout_width="fill_parent" android:src="@drawable/splashscreen" android:scaleType="fitXY" />
The only thing I do with this ImageView is set its visibility to GONE
when I'm finished starting.
Is there anything I can do about this?
java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@4721ec18 at android.graphics.Canvas.throwIfRecycled(Canvas.java:955) at android.graphics.Canvas.drawBitmap(Canvas.java:1044) at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:323) at android.widget.ImageView.onDraw(ImageView.java:923) at android.view.View.draw(View.java:6761) at android.view.ViewGroup.drawChild(ViewGroup.java:1663) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1390) at android.view.View.buildDrawingCache(View.java:6517) at android.view.View.getDrawingCache(View.java:6305) at android.view.ViewGroup.drawChild(ViewGroup.java:1588) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1390) at android.view.ViewGroup.drawChild(ViewGroup.java:1661) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1409) at android.view.View.draw(View.java:6764) at android.widget.FrameLayout.draw(FrameLayout.java:352) at android.view.ViewGroup.drawChild(ViewGroup.java:1663) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1390) at android.view.ViewGroup.drawChild(ViewGroup.java:1661) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1390) at android.view.ViewGroup.drawChild(ViewGroup.java:1661) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1390) at android.view.View.draw(View.java:6764) at android.widget.FrameLayout.draw(FrameLayout.java:352) at android.view.ViewGroup.drawChild(ViewGroup.java:1663) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1390) at android.view.ViewGroup.drawChild(ViewGroup.java:1661) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1390) at android.view.View.draw(View.java:6764) at android.widget.FrameLayout.draw(FrameLayout.java:352) at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1887) at android.view.ViewRoot.draw(ViewRoot.java:1432) at android.view.ViewRoot.performTraversals(ViewRoot.java:1167) at android.view.ViewRoot.handleMessage(ViewRoot.java:1764) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:143) at android.app.ActivityThread.main(ActivityThread.java:5068) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) at dalvik.system.NativeStart.main(Native Method)
This exception occurs when you try to recycle or use a recycled bitmap. You should not remove bitmap.recycle() function from your existing code, it may cause Out Of Memory Error. You can try this below code to fix the issue.
BitmapDrawable bitmapDrawable = ((BitmapDrawable) profileWallpaper.getDrawable()); if (null != bitmapDrawable && !bitmapDrawable.getBitmap().isRecycled()) { bitmapDrawable.getBitmap().recycle(); } else { log("bitmap is already recycled"); } bitmapDrawable = null;
Note: profileWallpaper is your imageView object
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With