Android 开发者控制台中的神秘堆栈跟踪(位图大小超过 32 位) [英] Mysterious stacktrace in Android developer console (bitmap size exceeds 32bits)

查看:28
本文介绍了Android 开发者控制台中的神秘堆栈跟踪(位图大小超过 32 位)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在开发者控制台中得到以下堆栈跟踪.有些报告说应用程序无法启动"或启动时崩溃".

I'm getting the following stacktrace in the developer console. Some report say "the application won't start" or "crash at startup".

我不知道该怎么做,它在我的应用程序类中没有提及任何内容!有人遇到同样的错误并找到了解决方法吗?

I don't know what to do, it doesn't mention any on my app's class! Anyone got the same error and found a fix?

java.lang.IllegalArgumentException: bitmap size exceeds 32bits
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:695)
at android.view.View.buildDrawingCache(View.java:6646)
at android.view.ViewGroup.onAnimationStart(ViewGroup.java:1345)
at android.view.ViewGroup.drawChild(ViewGroup.java:1591)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.View.draw(View.java:6996)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.View.draw(View.java:6996)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2054)
at android.view.ViewRoot.draw(ViewRoot.java:1632)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1335)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1991)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4358)
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)

推荐答案

如果是数量问题,你必须回收您的位图.
如果是大小问题(您不能加载太大的图像),则必须加载位图的较轻副本.

if it 's a matter of quantity, you have to recycle your bitmaps.
if it's a matter of size (you can't load too big images), you have to load a lighter copy of your bitmap.

这是创建较小图像的代码

Here is the code to create a smaller image

Options thumbOpts = new Options();
thumbOpts.inSampleSize = 4;
Bitmap bmp = BitmapFactory.decodeFile(imagePath, mThumbOpts);

inSampleSize 设置为 > 1 的值, 请求解码器对原始图像进行二次采样,返回较小的图像以节省内存.
使用 2 的幂以提高效率.

inSampleSize set to a value > 1, requests the decoder to subsample the original image, returning a smaller image to save memory.
Use a power of 2 for it to be more efficient.

这个帖子可能有用

这篇关于Android 开发者控制台中的神秘堆栈跟踪(位图大小超过 32 位)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆