我的代码在我的摩托罗拉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)
答案 0 :(得分:1)
如果没有看到您的代码和布局,很难准确,但是内存不足。它看起来与加载位图对象有关,在布局文件的第16行引用了该对象。
我建议您使用非常大的图像文件;你正在使用大量的图像;或两者的结合。
它在Droid上运行但在模拟器上运行的原因很可能是模拟器配置的内存少于手机。您可以在AVD管理器中更改模拟器设置。