我偶尔会收到以下异常。这种情况很少发生,以至于我无法找出任何可能触发它的情况——我主要在其他用户的 Flurry 异常报告中看到它。它可能与切换出和返回活动(例如使用“主页”按钮)有关,但这只是猜测。
class java.lang.RuntimeException android.graphics.Canvas.throwIfRecycled:955 (Canvas: trying to use a recycled bitmap android.graphics.Bitmap@30095b30)
完整的 LogCat 转储在这里: http://pastebin.com/2RjjgWHH
我已经查看了相关问题,但没有一个它们似乎适用。问题是,我没有手动回收任何位图。我没有加载大位图或操作位图。我的整个应用程序中有一个单个微小 ImageView
图标,从 XML 布局加载,除了切换包含的 VISIBLE
和 GONE
之间的 >LinearLayout。基本上,应用程序中唯一的其他内容是两个 WebView
、一个 TextView
和一个 ProgressDialog
。
<ImageView android:id="@+id/imageView1" android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/icon_a" android:focusableInTouchMode="false" android:focusable="false" android:layout_gravity="center_horizontal"></ImageView>
在 VISIBLE
和 GONE 之间切换时,您需要对 ImageView
执行一些特殊操作以防止其被回收,或者检查并刷新它(如果被回收) ?大多数时候它工作得很好。
I'm very occasionally receiving the following exception. It occurs so rarely that I haven't been able to figure out any circumstances that might trigger it -- I've mostly seen it in Flurry exception reports from other users. It could potentially be related to switching out of and back to the activity (e.g. with the Home button), but that's only a guess.
class java.lang.RuntimeException android.graphics.Canvas.throwIfRecycled:955 (Canvas: trying to use a recycled bitmap android.graphics.Bitmap@30095b30)
Full LogCat dump here: http://pastebin.com/2RjjgWHH
I've looked through related questions, but none of them seem to apply. The thing is, I'm not manually recycling any bitmaps. I'm not loading large bitmaps or manipulating bitmaps. I have a single, tiny ImageView
icon in my entire app, loaded from an XML layout, and I don't do anything with it programmatically except for switching the containing LinearLayout
between VISIBLE
and GONE
. Basically the only other things in the app are two WebView
s, a TextView
and a ProgressDialog
.
<ImageView android:id="@+id/imageView1" android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/icon_a" android:focusableInTouchMode="false" android:focusable="false" android:layout_gravity="center_horizontal"></ImageView>
Is there something special you need to do with an ImageView
to keep it from being recycled, or check and refresh it if recycled, when switching it between VISIBLE
and GONE
? Most of the time it works perfectly.
发布评论
评论(1)
此异常是由广告 SDK 引起的,并已在最近的 SDK 版本中修复。
This exception was caused by an advertising SDK, and has been fixed in a recent SDK release.