命名空间 'app' 未绑定,在 Android Studio 中带有来自 Maven 的外部库

Namespace 'app' not bound, in Android Studio with external lib from Maven

每当我尝试为外部库 UI 元素指定属性时,我都得到命名空间 'app' 未绑定。

        <LinearLayout
            android:id="@+id/card_database"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:clickable="true"
            android:onClick="dbclicked"
            android:orientation="horizontal"
            android:background="#ffff7f31"
            >

            <ImageView
                android:id="@+id/img_database"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/db"
                />

            <TextView
                android:id="@+id/txt_database"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="center_vertical"
                android:paddingStart="15dp"
                android:text="@string/db"
                android:textColor="#ffffff"
                android:textSize="20sp"
                android:autoText="false" />
        </LinearLayout>
        </com.balysv.materialripple.MaterialRippleLayout>

编译 'com.balysv:material-ripple:1.0.0' 在 build.gradle 中使用,我是 运行 最新版本的 Android Studio 有更新。

添加

xmlns:app="http://schemas.android.com/apk/res-auto"

到你的根元素

只需 select 错误(用鼠标触摸错误)并按下。 "ALT+ENTER"会自动解决错误

所以我已经打开了大约 10 个问题来尝试解决这个问题,但所有的解决方案都不适合我。我将 post 针对与此问题类似的所有其他问题,以防其他人陷入我的困境。

对我有用的: 打开工具> SDK 管理器然后按编辑 SDK 位置。现在记下位置,使用 windows 资源管理器打开它,将 SDK 文件夹复制到另一个位置,例如桌面、文档。完成后返回编辑 SDK 位置,然后选择粘贴 SDK 文件夹的新位置,按下一步,然后等待。它应该是固定的。

像这样将 xmlns:app="http://schemas.android.com/apk/res-auto" 添加到 root:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:orderInCategory="1"
        app:showAsAction = "ifRoom"
        />

</menu>