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); }

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念