Android 开发者控制台中神秘的堆栈跟踪(位图大小超过 32 位)

发布于 2025-01-07 15:58:22 字数 1812 浏览 5 评论 0原文

我在开发者控制台中收到以下堆栈跟踪。一些报告称“应用程序无法启动”或“启动时崩溃”。

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

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)

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

怪我鬧 2025-01-14 15:58:22

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

以下是创建较小图像的代码

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

inSampleSize设置一个值> 1、请求解码器对原始图像进行子采样,返回较小的图像以节省内存。
使用 2 的幂会更有效。

这篇文章 可能有用

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 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.

This post may be useful

空‖城人不在 2025-01-14 15:58:22

Bitmap.createBitmap()

抛出IllegalArgumentException

如果 x、y、宽度、高度值超出源位图的尺寸,或者宽度 <= 0,或者高度 <= 0

首先确保您的 x、y、宽度和高度值小于源位图。

对我来说问题是矩阵。我的矩阵有一个平移值,该值将其中一个值带到输入位图的边界之外。

希望这有帮助

Bitmap.createBitmap()

Throws IllegalArgumentException

if the x, y, width, height values are outside of the dimensions of the source bitmap, or width is <= 0, or height is <= 0

First make sure your x, y, width and height values are smaller than the source bitmap.

The issue for me was the matrix. My matrix has a translation value which brought the one of the values outside of the bounds of the input bitmap.

Hope this helps

执笏见 2025-01-14 15:58:22

就我而言,此字符串中有错误:

WebView.getSettings().setUseWideViewPort(true);

Crash was only on API 18 and less

In my case it was error in this string:

WebView.getSettings().setUseWideViewPort(true);

Crash was only on API 18 and less

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文