Caused by: android.view.InflateException: Binary XML file line #57: Error inflating class null

错误原因是因为我在xml布局文件中讲View写成了view(注意首字母的大小写区分)

错误代码如下

<view android:layout_width="fill_parent"
          android:layout_height="1dp"
          android:background="#000"
          android:layout_below="@+id/set_tag"
          android:layout_marginBottom="20dp"/>

错误日志如下

01-28 14:41:59.893    5425-5425/com.dl.news E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.dl.news, PID: 5425
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dl.news/com.dl.news.ui.ArticleDetailActivity}: android.view.InflateException: Binary XML file line #57: Error inflating class null
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2215)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2264)
            at android.app.ActivityThread.access$800(ActivityThread.java:136)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1219)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5032)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: android.view.InflateException: Binary XML file line #57: Error inflating class null
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:302)
            at android.app.Activity.setContentView(Activity.java:1980)
            at com.dl.news.ui.ArticleDetailActivity.onCreate(ArticleDetailActivity.java:56)
            at android.app.Activity.performCreate(Activity.java:5310)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2179)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2264)
            at android.app.ActivityThread.access$800(ActivityThread.java:136)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1219)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5032)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.NullPointerException
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:693)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:302)
            at android.app.Activity.setContentView(Activity.java:1980)
            at com.dl.news.ui.ArticleDetailActivity.onCreate(ArticleDetailActivity.java:56)
            at android.app.Activity.performCreate(Activity.java:5310)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2179)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2264)
            at android.app.ActivityThread.access$800(ActivityThread.java:136)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1219)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5032)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
            at dalvik.system.NativeStart.main(Native Method)

转自:Caused by: android.view.InflateException: Binary XML file line #57: Error inflating class null

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐