无法启动活动(二进制XML文件行#0:错误膨胀类未知)

时间:2018-02-16 14:01:43

标签: java android xml

运行Presences系统时出错。像这样的东西(当打开ListOnline时)。我的应用程序停止并且我在第0行上出现了二进制XML文件错误。这有点奇怪,因为我没有看到像0这样的问题,所以我需要你的帮助,每个人。谢谢!

02-16 20:47:32.126 10542-10542/com.mystogan.presense E/AndroidRuntime: FATAL EXCEPTION: main
                                                                       Process: com.mystogan.presense, PID: 10542
                                                                       java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mystogan.presense/com.mystogan.presense.ListOnline}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class <unknown>
                                                                           at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
                                                                           at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
                                                                           at android.app.ActivityThread.-wrap11(Unknown Source:0)
                                                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
                                                                           at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                           at android.os.Looper.loop(Looper.java:164)
                                                                           at android.app.ActivityThread.main(ActivityThread.java:6494)
                                                                           at java.lang.reflect.Method.invoke(Native Method)
                                                                           at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
                                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
                                                                        Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class <unknown>
                                                                        Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class <unknown>
                                                                        Caused by: java.lang.reflect.InvocationTargetException
                                                                           at java.lang.reflect.Constructor.newInstance0(Native Method)
                                                                           at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
                                                                           at android.view.LayoutInflater.createView(LayoutInflater.java:647)
                                                                           at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
                                                                           at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
                                                                           at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
                                                                           at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
                                                                           at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
                                                                           at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                                                                           at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
                                                                           at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
                                                                           at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
                                                                           at com.mystogan.presense.ListOnline.onCreate(ListOnline.java:26)
                                                                           at android.app.Activity.performCreate(Activity.java:7000)
                                                                           at android.app.Activity.performCreate(Activity.java:6991)
                                                                           at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
                                                                           at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
                                                                           at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
                                                                           at android.app.ActivityThread.-wrap11(Unknown Source:0)
                                                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
                                                                           at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                           at android.os.Looper.loop(Looper.java:164)
                                                                           at android.app.ActivityThread.main(ActivityThread.java:6494)
                                                                           at java.lang.reflect.Method.invoke(Native Method)
                                                                           at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
                                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

activity_list_online.xml

&#13;
&#13;
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.mystogan.presense.ListOnline">
    
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolBar"
        android:minHeight="?attr/actionBarSize"
        android:minWidth="?attr/colorPrimary"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:title="@android:color/white">
    </android.support.v7.widget.Toolbar>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/listOnline"
        android:layout_below="@id/toolBar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>

</RelativeLayout>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:2)

width应该是一些数字值后跟dp

因此问题在android:minWidth="?attr/colorPrimary",其中颜色值类似于#aa33ff

您可以将所需的宽度设为android:minWidth="200dp"`