android.view.InflateException: Binary XML file line #12: Error inflating class...问题

来源:互联网 发布:sqlserver获取当前时间 编辑:程序博客网 时间:2024/06/03 17:44
遇到 android.view.InflateException: Binary XML file line #12: Error inflating class...

这种问题除了常见的1. 尺寸/字符串/图片资源没有找到, 2.缺少构造方法 等常见的原因外还有可能是内存泄漏OOM造成的,

参考:android.view.InflateException: Binary XML file line #12: Error inflating class <unknown>



android.view.InflateException: Binary XML file line #12: Error inflating class <unknown>

up vote89down votefavorite
29

I am receiving many errors of kind displayed in the subj. These errors seems to be occasional and I cannot reproduce them. From stack I can learn that such error may occurs for my different layout resources. The line of XML is also varying.

Can anybody explain why this error occurs? And what I can do to fix this problem?

Stack

=============================================================com.fsp.android.f generated the following exception:java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fsp.android.f/com.life360.android.ui.tour.TourActivity}: android.view.InflateException: Binary XML file line #12: Error inflating class <unknown>--------- Stack trace ---------1. android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2649)2. android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2674)3. android.app.ActivityThread.access$2200(ActivityThread.java:131)4. android.app.ActivityThread$H.handleMessage(ActivityThread.java:1975)5. android.os.Handler.dispatchMessage(Handler.java:99)6. android.os.Looper.loop(Looper.java:123)7. android.app.ActivityThread.main(ActivityThread.java:4702)8. java.lang.reflect.Method.invokeNative(Native Method)9. java.lang.reflect.Method.invoke(Method.java:521)10. com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)11. com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)12. dalvik.system.NativeStart.main(Native Method)------------------------------------------ Cause -----------android.view.InflateException: Binary XML file line #12: Error inflating class <unknown>1. android.view.LayoutInflater.createView(LayoutInflater.java:513)2. com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)3. android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)4. android.view.LayoutInflater.rInflate(LayoutInflater.java:618)5. android.view.LayoutInflater.rInflate(LayoutInflater.java:621)6. android.view.LayoutInflater.inflate(LayoutInflater.java:382)7. android.view.LayoutInflater.inflate(LayoutInflater.java:320)8. android.view.LayoutInflater.inflate(LayoutInflater.java:276)9. com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:208)10. android.app.Activity.setContentView(Activity.java:1629)11. com.solvek.sample.ui.BaseActivity.onCreate(BaseActivity.java:23)12. com.solvek.sample.ui.tour.TourActivity.onCreate(TourActivity.java:161)13. android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)14. android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2587)15. android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2674)16. android.app.ActivityThread.access$2200(ActivityThread.java:131)17. android.app.ActivityThread$H.handleMessage(ActivityThread.java:1975)18. android.os.Handler.dispatchMessage(Handler.java:99)19. android.os.Looper.loop(Looper.java:123)20. android.app.ActivityThread.main(ActivityThread.java:4702)21. java.lang.reflect.Method.invokeNative(Native Method)22. java.lang.reflect.Method.invoke(Method.java:521)23. com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)24. com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)25. dalvik.system.NativeStart.main(Native Method)------------------------------------- Environment --------Time =2010-12-20 08:27:35 AMDevice =tmobile/htc_espresso/espresso/espresso:2.1-update1/ERE27/216830:user/release-keysMake =HTCModel =T-Mobile myTouch 3G SlideProduct =htc_espressoApp =com.fsp.android.f, version 2.0.9 (build 1232)


up vote190down voteaccepted

The inflate exception is not actually the problem, but really comes from another deeper issue in your layout that is then wrapped in an InflateException. A common issue is an out of memory exception when trying to inflate an imageview loading a drawable resource. If one of this resources has a high pixel resolution it would take a lot of memory causing then an inflate exception.

So basically verify that the pixel resolution in your drawables images are just the minimum necessary for your layout.

shareimprove this answer
  

阅读全文
0 0
原创粉丝点击