`

Binary XML file line #101: Error inflating class

阅读更多

app需要兼容多种分辨率的设备,一般的情况下,布局文件,都会提供多套出来,供自动匹配。

但调试修改布局文件的情况下,经常会报如下错误:

android.view.InflateException: Binary XML file line #101: Error inflating class 


完整错误:

06-10 10:51:53.571: D/dalvikvm(9158): GC_FOR_ALLOC freed 38K, 4% free 9184K/9543K, paused 14ms, total 14ms
06-10 10:51:53.601: D/dalvikvm(9158): GC_CONCURRENT freed 6K, 3% free 12937K/13319K, paused 2ms+2ms, total 19ms
06-10 10:51:53.681: D/dalvikvm(9158): GC_FOR_ALLOC freed 3760K, 28% free 10848K/15047K, paused 12ms, total 12ms
06-10 10:51:53.711: W/ResourceType(9158): Failure getting entry for 0x7f020050 (t=1 e=80) in package 0 (error -75)
06-10 10:51:53.711: W/dalvikvm(9158): threadid=1: thread exiting with uncaught exception (group=0x40c19438)
06-10 10:51:53.721: E/AndroidRuntime(9158): FATAL EXCEPTION: main
06-10 10:51:53.721: E/AndroidRuntime(9158): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.foxhis.activity/com.foxhis.activity.LoginActivity}: android.view.InflateException: Binary XML file line #101: Error inflating class
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2067)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2092)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3520)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.app.ActivityThread.access$700(ActivityThread.java:133)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.os.Looper.loop(Looper.java:137)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.app.ActivityThread.main(ActivityThread.java:4800)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at java.lang.reflect.Method.invokeNative(Native Method)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at java.lang.reflect.Method.invoke(Method.java:511)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:564)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at dalvik.system.NativeStart.main(Native Method)
06-10 10:51:53.721: E/AndroidRuntime(9158): Caused by: android.view.InflateException: Binary XML file line #101: Error inflating class
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.view.LayoutInflater.createView(LayoutInflater.java:613)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:260)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.app.Activity.setContentView(Activity.java:1867)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at com.foxhis.activity.LoginActivity.onCreate(LoginActivity.java:74)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.app.Activity.performCreate(Activity.java:5008)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2031)
06-10 10:51:53.721: E/AndroidRuntime(9158):     ... 12 more
06-10 10:51:53.721: E/AndroidRuntime(9158): Caused by: java.lang.reflect.InvocationTargetException
06-10 10:51:53.721: E/AndroidRuntime(9158):     at java.lang.reflect.Constructor.constructNative(Native Method)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.view.LayoutInflater.createView(LayoutInflater.java:587)
06-10 10:51:53.721: E/AndroidRuntime(9158):     ... 28 more
06-10 10:51:53.721: E/AndroidRuntime(9158): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f020050 a=-1 r=0x7f020050}
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.content.res.Resources.loadDrawable(Resources.java:1933)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.view.View.(View.java:3336)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.widget.TextView.(TextView.java:447)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.widget.Button.(Button.java:107)
06-10 10:51:53.721: E/AndroidRuntime(9158):     at android.widget.Button.(Button.java:103)
06-10 10:51:53.721: E/AndroidRuntime(9158):     ... 31 more

 提示信息上面,会指明是哪一个Activity对应的Layout出现了布局。
 按照提示去查看该layout,会发现,没有哪里出问题。这就怪了。

 

 其实仔细查看,就会发现,不同分辨率下面,该布局文件所引用的资源,是有缺失的。

当调试分辨率是1024x768的layout时,我们添加了一张图片,但是我们习惯性的只是放在该分辨率下面的资源文件夹下面,那么就导致了,当我用1280x800这样的设备跑程序时,出现上述的问题。

 

解决方法:

       把所有分辨率下面的资源文件中,都更新掉刚做的修改。添加文件时,所有分辨率下面都添加,删除时,都删除。做到同进退,上面这样的问题就不会出现了。

 

 附上其他类似bug的解决方法:

     http://blog.csdn.net/harry_helei/article/details/7265610


 

总结:

       类似的XML错误,大部分都是因为资源文件的来回引用引起的。

       只要留意资源文件的命名,引用,后缀等等,即可避免

 


 

 

 

  • 大小: 16.9 KB
分享到:
评论

相关推荐

    BUG修改日记 – Android Fragment初学 – Binary XML file line #XX: Error inflating class fragment

    第一次写博,如有不对,多多海涵。 背景: 最近学校Android课要求练习 第一行代码Android 上4.5新闻app实践,要使用到 fragment,recyclerview等控件,但按照书上按部就班写出来后,出现app无法打开情况。...

    Android-Android库路由XML在inflating布局文件时将标签从一个标签转移到另一个标签

    本篇文章将深入探讨如何在Android库路由XML中进行布局文件的处理,特别是关于在inflating布局时将标签从一个标签转移到另一个标签的操作。 首先,理解Android的布局inflation过程至关重要。Inflation是将XML布局...

    Fragment两种

    android.view.InflateException: Binary XML file line #7: Error inflating class fragment异常 ( 2 ) android.support.v4.app.Fragment:可以兼容到1.6的版本,不能使用标签,需要在程序中通过add或者replace的...

    google-play-services.jar

    google map v2中遇见xml里frment找不到问题 可以引入这个jar包就可以了 如Caused by: android.view.InflateException: Binary XML file line #3: Error inflating class fragment

    recyclerview-V7

    Unable to start activity ComponentInfo{com.deyi.deyijia/com.deyi.deyijia.activity.PinterestActivity}: android.view.InflateException: Binary XML file line #157: Error inflating class android.support....

    recyclerview-v7.zip

    Unable to start activity ComponentInfo{com.deyi.deyijia/com.deyi.deyijia.activity.PinterestActivity}: android.view.InflateException: Binary XML file line #157: Error inflating class android.support....

    android实现常驻通知栏遇到的问题及解决办法

    Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout 报错信息表明,这个问题是由于布局文件中的错误所引起的,具体来说,是由于 android.support.constraint....

    ERROR/AndroidRuntime(17121)的问题解决

    在layout文件中使用自定义的View时遇到如下错误: 12-11 17:28:26.962: ERROR/AndroidRuntime(17121): android.view.InflateException: Binary XML file line #6: Error inflating class fish.apps.ipcall.controls...

    Android 兼容性问题:java.lang.UnsupportedOperationException解决办法

    android.view.InflateException: Binary XML file line #13: Error inflating class at android.view.LayoutInflater.createView(LayoutInflater.java:613) at com.android.internal.policy.impl.P

    Android实现在xml文件中引用自定义View的方法分析

    Java.lang.RuntimeException: Unable to start activity ComponentInfo{cm.test/cm.test.TestsActivity}:Android.view.InflateException: Binary XML file line #8: Error inflating class com.test.testview ...

    解析android res 运行错误的问题

    其次,`android.view.InflateException: Binary XML file line #279: Error inflating class <unknown>` 异常通常出现在布局文件解析时,无法找到或实例化指定的视图类。这可能是因为以下原因: 1. **拼写错误或类名...

    apktool documentation

    inflating: res/xml/literals.xml inflating: res/xml/references.xml extracting: resources.arsc However, at this point you have simply inflated compiled sources. If you tried to view AndroidManifest....

Global site tag (gtag.js) - Google Analytics