android - 由于找不到 View ID,项目外部的文件导致构建失败

标签 android xml gradle layout

enter image description here

我不知道是什么原因造成的。我唯一添加的是 recyclerview 和 cardview 到项目中。然后,它停止工作。我仔细检查了我的 @id 是否都是 @+id 但仍然没有任何变化。

我缩小了错误范围:只有当我将此 TextView 的 Id 从我指定的任何内容更改为 title 时,它才会停止发生 enter image description here

这是 View :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.CardView
    android:id="@+id/card_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:elevation="3dp">

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

        <TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="11dp"
            android:text="Event Title"
            android:textAppearance="@style/TextAppearance.AppCompat.Display1" />

        <ImageView
            android:id="@+id/eventCardImage"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/title"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="13dp"
            android:clickable="true"
            app:srcCompat="@mipmap/ic_launcher" />

        <TextView
            android:id="@+id/eventCardDescription"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/eventCardImage"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="21dp"
            android:text="Big Long Event Description"
            android:textAppearance="@style/TextAppearance.AppCompat.Body2" />
    </RelativeLayout>

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

这真的很烦人。我想这是在构建过程中发生的一个生成的事情,里面有一个硬编码的标题,或者我做错了什么。

编辑:发现错误 编辑:截图 编辑:发布 XML

最佳答案

尝试重建项目,希望它能在不尝试重启 android studio 的情况下正常工作。 如果您使用的是 cardview 或 recycle-view,请确保您已添加所需的 gradle 依赖项。 用作引用时从 id 中删除 + 号。 将 android:layout_below="@+id/title"替换为 android:layout_below="@id/title"

关于android - 由于找不到 View ID,项目外部的文件导致构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46073679/

相关文章:

cordova - Task.leftShift(Closure) 方法已被弃用

java - 如何在另一个类中设置按钮属性和操作,并在 android 的 Activity 类中使​​用它们

android - 保存 Activity_main.xml 时遇到问题

c# - 如何反序列化一个xml字符串

c# - 使用 XSD 验证 XML 时忽略提供的命名空间

java - Gradle-将依赖项与 Artifact 中的其他项目一起使用

visual-studio - Cordova gradle 版本

android - 你能在 Eclipse 中禁用 DDMS

java - Eclipse 在 Android 项目构建中卡住

获取一个节点的 jQuery 方法——而不是 find();