发生了Android Inflate异常

时间:2012-02-11 10:35:18

标签: android memory

我必须为此内存问题做些什么?

02-11 15:40:30.959: E/AndroidRuntime(5108): FATAL EXCEPTION: main
02-11 15:40:30.959: E/AndroidRuntime(5108): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.firewards/com.firewards.Menu}: android.view.InflateException: Binary XML file line #122: Error inflating class <unknown>
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.os.Looper.loop(Looper.java:123)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.app.ActivityThread.main(ActivityThread.java:3729)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at java.lang.reflect.Method.invokeNative(Native Method)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at java.lang.reflect.Method.invoke(Method.java:507)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:874)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:632)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at dalvik.system.NativeStart.main(Native Method)
02-11 15:40:30.959: E/AndroidRuntime(5108): Caused by: android.view.InflateException: Binary XML file line #122: Error inflating class <unknown>
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.view.LayoutInflater.createView(LayoutInflater.java:518)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.app.Activity.setContentView(Activity.java:1657)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at com.firewards.Menu.onCreate(Menu.java:66)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
02-11 15:40:30.959: E/AndroidRuntime(5108):     ... 11 more
02-11 15:40:30.959: E/AndroidRuntime(5108): Caused by: java.lang.reflect.InvocationTargetException
02-11 15:40:30.959: E/AndroidRuntime(5108):     at java.lang.reflect.Constructor.constructNative(Native Method)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.view.LayoutInflater.createView(LayoutInflater.java:505)
02-11 15:40:30.959: E/AndroidRuntime(5108):     ... 27 more
02-11 15:40:30.959: E/AndroidRuntime(5108): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.content.res.Resources.loadDrawable(Resources.java:1709)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.view.View.<init>(View.java:1951)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.widget.ImageView.<init>(ImageView.java:112)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.widget.ImageButton.<init>(ImageButton.java:85)
02-11 15:40:30.959: E/AndroidRuntime(5108):     at android.widget.ImageButton.<init>(ImageButton.java:81)
02-11 15:40:30.959: E/AndroidRuntime(5108):     ... 30 more

1 个答案:

答案 0 :(得分:0)

是的,感觉就像内存问题一样,尝试在访问之前释放一些位图 特别观点。

我建议查看此视频http://dubroy.com/blog/google-io-memory-management-for-android-apps/,其中讨论了Android内存管理。

值得一提的是,在蜂窝之前,位图是在原生中分配的 堆,所以在分析内存时要注意它。 如果您使用的是Honeycomb或更新版本的设备,则会在托管中分配位图 堆。