Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android二进制布局膨胀异常:ClassNotFoundException:DIND';“找不到类”;android.view.layout“;在路径上:_Java_Android_Android Layout_Android Linearlayout - Fatal编程技术网

Java Android二进制布局膨胀异常:ClassNotFoundException:DIND';“找不到类”;android.view.layout“;在路径上:

Java Android二进制布局膨胀异常:ClassNotFoundException:DIND';“找不到类”;android.view.layout“;在路径上:,java,android,android-layout,android-linearlayout,Java,Android,Android Layout,Android Linearlayout,我的布局 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/tools" xmlns:card_view="http://sc

我的布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/tools"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="10dp"
        card_view:cardCornerRadius="4dp">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <FrameLayout
                android:id="@+id/header"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
                    android:id="@+id/profilePic"
                    android:layout_width="96dp"
                    android:layout_height="96dp"
                    android:layout_gravity="center_horizontal"
                    android:src="@drawable/avatar" />

            </FrameLayout>

            <RelativeLayout
                android:id="@+id/user_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/header">

                <ImageView
                    android:id="@+id/divider"
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:layout_marginBottom="5dp"
                    android:layout_marginTop="5dp"
                    android:src="@color/contentDividerLine" />

                <TextView
                    android:id="@+id/username"
                    style="@style/Base.Widget.AppCompat.Button.Borderless"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerHorizontal="true"
                    android:layout_gravity="bottom"
                    android:drawablePadding="5dp"
                    android:padding="8dp"
                    android:text="Name"
                    android:textColor="@color/Black" />


            </RelativeLayout>

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/user_view">

                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:layout_marginBottom="5dp"
                    android:layout_marginTop="5dp"
                    android:src="@color/contentDividerLine" />

                <TextView
                    android:id="@+id/email"
                    style="@style/Base.Widget.AppCompat.Button.Borderless"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerHorizontal="true"
                    android:layout_gravity="bottom"
                    android:drawablePadding="5dp"
                    android:padding="8dp"
                    android:text="Email"
                    android:textColor="@color/Black" />


            </RelativeLayout>
        </RelativeLayout>
    </android.support.v7.widget.CardView>

    <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="10dp"
        card_view:cardCornerRadius="4dp">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <RelativeLayout
                android:id="@+id/settings_header"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <TextView
                    android:id="@+id/settings_title"
                    style="@style/Base.Widget.AppCompat.Button.Borderless"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentStart="true"
                    android:layout_centerHorizontal="true"
                    android:layout_gravity="bottom"
                    android:drawablePadding="5dp"
                    android:padding="8dp"
                    android:text="Settings"
                    android:textColor="@color/Black" />

                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:layout_below="@id/settings_title"
                    android:layout_marginBottom="5dp"
                    android:layout_marginTop="5dp"
                    android:src="@color/contentDividerLine" />


            </RelativeLayout>

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/settings_header">

                <ScrollView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:orientation="vertical">

                        <include
                            layout="@layout/notification_pref"
                            app:label="@{@string/show_bounds}" />

                        <include
                            layout="@layout/location_pref"
                            app:label="@{@string/show_offsets}" />

                        <include
                            layout="@layout/sync_pref"
                            app:label="@{@string/show_bounds}" />

                        <include
                            layout="@layout/analytics_pref"
                            app:label="@{@string/show_offsets}" />

                    </LinearLayout>

                </ScrollView>
            </RelativeLayout>
        </RelativeLayout>
    </android.support.v7.widget.CardView>
</LinearLayout>

确保已将以下依赖项添加到
build.gradle
文件中:

compile 'de.hdodenhof:circleimageview:2.1.0'

xml命名空间必须是:

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"
因此,将线性布局编辑为:

<LinearLayout 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="wrap_content"
android:orientation="vertical"
tools:context=".MainActivity">

....

</LinearLayout>

这个问题肯定与无效的xml有关。
要进行故障排除,请确保可以找到xml文件中的所有元素。
您可以通过ctrl(或cmd)-单击所有布局项来验证这一点。
例如,当您没有为compat元素使用正确的名称空间时,可能会出现问题

当我在
build.gradle
中添加时,它对我很有效,所以你可以试试

android {
    //...
     dataBinding {
            enabled = true 
     }
}

错误被指定为:

原因:android.view.InflateException:二进制XML文件行#1: 二进制XML文件行#1:膨胀类布局时出错,原因是: android.view.InflateException:二进制XML文件行#1:错误 导致类布局膨胀的原因:java.lang.ClassNotFoundException: 在路径上未找到类“android.view.layout:

此错误是在应用程序中实现数据绑定时引起的。在这种情况下,用户正在使用数据绑定(请参见
app:label=
的指定值):

。。。
...
因此,我们需要在
/app/build.gradle
文件中添加块
数据绑定
,以便在我们的应用程序中使用它们

android {
    ...
    ...
    ...
    dataBinding {
        enabled = true
    }
}
解决此问题的另一种方法是定位包含的布局并删除标记,因为项目中未启用数据绑定


请参见

我相信这个问题没有一个特定的原因。 我尝试实现上面发布的所有解决方案

对我来说,问题在于我包括布局的方式

<include layout="@layout/feed_fail_layout" />


基本上,我将feed\u fail\u布局中包含的所有内容都添加到主布局中。

导致此异常的原因是您试图使用未膨胀的视图

在使用的情况下,我碰巧尝试导航到一个视图的目标,该视图在任何时候都不会在活动中膨胀(无论是否使用DI)。因此,请确保在
nav_图中的活动中没有不允许的操作


GL

也许这有帮助:您可以尝试删除'xmlns:card_view=“”'行吗?您是否检查了de.hdodenhof.circleimageview.circleimageview的路径?如果导入不成功,可能会产生此错误。请清除project并重新生成,然后运行project@MaxExplode你解决这个问题了吗?请发布您自己的答案或接受对您有效的答案。您可以从文档中添加参考资料或解释此代码的作用,以及它如何解决问题。完美答案!注意:必须为依赖于使用数据绑定的库的应用程序模块配置数据绑定,即使应用程序模块不直接使用数据绑定@克雷:本说明来自本文档页
android {
    ...
    ...
    ...
    dataBinding {
        enabled = true
    }
}
<include layout="@layout/feed_fail_layout" />