为什么我在模拟器上遇到 Inflate 异常,但在我的 Droid 上却没有?

发布于 2024-11-18 09:04:08 字数 1760 浏览 3 评论 0原文

我的代码在我的 Motorola Droid 上运行良好,但是当我在模拟器上运行它时,我得到以下堆栈跟踪:

07-05 14:29:23.035: ERROR/AndroidRuntime(237): Uncaught handler: thread main exiting due to uncaught      exception
07-05 14:29:23.075: ERROR/AndroidRuntime(237): java.lang.RuntimeException: Unable to start activity        ComponentInfo{com.thinknao.wordlands/com.thinknao.wordlands.OptionsPage}:         android.view.InflateException: Binary XML file line #16: Error inflating class java.lang.reflect.Constructor
07-05 14:29:23.075: ERROR/AndroidRuntime(237):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401)
07-05 14:29:23.075: ERROR/AndroidRuntime(237):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)

07-05 14:29:23.075: ERROR/AndroidRuntime(237): Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class java.lang.reflect.Constructor
07-05 14:29:23.075: ERROR/AndroidRuntime(237):     at android.view.LayoutInflater.createView(LayoutInflater.java:512)
07-05 14:29:23.075: ERROR/AndroidRuntime(237):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
07-05 14:29:23.075: ERROR/AndroidRuntime(237):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:562)

07-05 14:29:23.075: ERROR/AndroidRuntime(237): Caused by: java.lang.reflect.InvocationTargetException
07-05 14:29:23.075: ERROR/AndroidRuntime(237):     at android.widget.Button.<init>(Button.java:65)

07-05 14:29:23.075: ERROR/AndroidRuntime(237): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
07-05 14:29:23.075: ERROR/AndroidRuntime(237):     at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)

My code runs fine on my Motorola Droid but when i run it on the emulator i get this stack trace:

07-05 14:29:23.035: ERROR/AndroidRuntime(237): Uncaught handler: thread main exiting due to uncaught      exception
07-05 14:29:23.075: ERROR/AndroidRuntime(237): java.lang.RuntimeException: Unable to start activity        ComponentInfo{com.thinknao.wordlands/com.thinknao.wordlands.OptionsPage}:         android.view.InflateException: Binary XML file line #16: Error inflating class java.lang.reflect.Constructor
07-05 14:29:23.075: ERROR/AndroidRuntime(237):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401)
07-05 14:29:23.075: ERROR/AndroidRuntime(237):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)

07-05 14:29:23.075: ERROR/AndroidRuntime(237): Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class java.lang.reflect.Constructor
07-05 14:29:23.075: ERROR/AndroidRuntime(237):     at android.view.LayoutInflater.createView(LayoutInflater.java:512)
07-05 14:29:23.075: ERROR/AndroidRuntime(237):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
07-05 14:29:23.075: ERROR/AndroidRuntime(237):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:562)

07-05 14:29:23.075: ERROR/AndroidRuntime(237): Caused by: java.lang.reflect.InvocationTargetException
07-05 14:29:23.075: ERROR/AndroidRuntime(237):     at android.widget.Button.<init>(Button.java:65)

07-05 14:29:23.075: ERROR/AndroidRuntime(237): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
07-05 14:29:23.075: ERROR/AndroidRuntime(237):     at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)

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

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

发布评论

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

评论(1

清秋悲枫 2024-11-25 09:04:08

如果不查看代码和布局,很难准确判断,但内存不足。它看起来与位图对象的加载有关,该对象在布局文件的第 16 行引用。

我建议您要么使用非常大的图像文件;您使用了大量图像;或两者的组合。

它在 Droid 上运行但不在模拟器上运行的原因很可能是模拟器配置的内存比手机少。您可以在 AVD 管理器中更改模拟器设置。

It's difficult to be exact without seeing your code and layout, but you are running out of memory. It looks to be concerned with the loading of a bitmap object, one that is referenced on line 16 of your layout file.

I would suggest that either you are using a very large image file; you are using lots of images; or a combination of the two.

The reason that it runs on the Droid but not on the emulator is, most likely, that the emulator has been configured with less memory than the phone. You can change your emulator settings in the AVD manager.

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