微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

InflateException:Binary XML file line #105: Error inflating class <unknown>

项目在某些手机上偶尔会发生以下异常log:

com.sogou.map.android.maps\ncom.sogou.map.android.maps\nuncaught exception at Fri Apr 10 03:46:19 GMT+08:00 2015\nandroid.view.InflateException: Binary XML file line #105: Error inflating class <unkNown>

android.view.LayoutInflater.createView(LayoutInflater.java:623)

com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)

android.view.LayoutInflater.onCreateView(LayoutInflater.java:672)

android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)\n\tat android.view.LayoutInflater.rInflate(LayoutInflater.java:758)

android.view.LayoutInflater.rInflate(LayoutInflater.java:761)\n\tat android.view.LayoutInflater.inflate(LayoutInflater.java:495)

android.view.LayoutInflater.inflate(LayoutInflater.java:400)\n\tat android.view.LayoutInflater.inflate(LayoutInflater.java:353)

android.view.View.inflate(View.java:17483)\n\tat


java代码中是通过View.inflate加载布局文件

布局文件xml文件对应105行是个系统的FrameLayout

<FrameLayout
android:layout_width="165dp"
android:layout_height="165dp"
android:background="@drawable/pic" >
</FrameLayout>


上网找资料找了好久,可能的情况是pic的图片太大,inflate时候造成VM内存溢出,inflate过程抛出InflateException

所以减小pic的大小

或者可以通过

try { view = View.inflate(context,R.layout.main,null); } catch (InflateException e) { System.gc(); view =View.inflate(context,null); }

原文地址:https://www.jb51.cc/xml/296938.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。