首页 > 解决方案 > 在 android studio 中导入项目后,XML 文件中出现一些错误,例如 URI 无法识别

问题描述

我在 android studio 中导入了项目,然后在 XML 文件中存在多个 URI 错误,即 URI 无法识别,并且 XML 文件无法理解 android 资源及其元素以及 textView 等。

显示 XML 样式标记的 Android Studio 窗口

这是我的 XML 文件代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/tan_background"
    android:orientation="vertical"
    tools:context="com.example.android.miwok.MainActivity">

    <TextView
        android:id="@+id/numbers"
        style="@style/CategoryStyle"
        android:background="@color/category_numbers"
        android:text="@string/category_numbers" />

    <TextView
        android:id="@+id/family"
        style="@style/CategoryStyle"
        android:background="@color/category_family"
        android:text="@string/category_family" />

    <TextView
        android:id="@+id/colors"
        style="@style/CategoryStyle"
        android:background="@color/category_colors"
        android:text="@string/category_colors" />

    <TextView
        android:id="@+id/phrases"
        style="@style/CategoryStyle"
        android:background="@color/category_phrases"
        android:text="@string/category_phrases" />

</LinearLayout>

这是我的 string.xml 文件:

<resources>
    <!-- Title for the application. [CHAR LIMIT=12] -->
    <string name="app_name">Miwok</string>

    <!-- Category name for phrases [CHAR LIMIT=20] -->
    <string name="category_phrases">Phrases</string>

    <!-- Category name for the vocabulary words for colors [CHAR LIMIT=20] -->
    <string name="category_colors">Colors</string>

    <!-- Category name for the vocabulary words for numbers [CHAR LIMIT=20] -->
    <string name="category_numbers">Numbers</string>

    <!-- Category name for the vocabulary words for family members [CHAR LIMIT=20] -->
    <string name="category_family">Family Members</string>
</resources>

将项目与 gradle 文件同步: 在此处输入图像描述

标签: xmlfileelement

解决方案


我前段时间也遇到过这个问题。

要解决此问题,请从您的计算机中删除以下目录: C:\Users\your-username\.gradle\

在此之后,打开您的项目,使缓存无效并重新启动 android studio,然后将您的项目与 gradle 文件同步。


推荐阅读