xml - 在 android studio 中导入项目后,XML 文件中出现一些错误,例如 URI 无法识别
问题描述
我在 android studio 中导入了项目,然后在 XML 文件中存在多个 URI 错误,即 URI 无法识别,并且 XML 文件无法理解 android 资源及其元素以及 textView 等。
这是我的 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 文件同步: 在此处输入图像描述
解决方案
我前段时间也遇到过这个问题。
要解决此问题,请从您的计算机中删除以下目录:
C:\Users\your-username\.gradle\
在此之后,打开您的项目,使缓存无效并重新启动 android studio,然后将您的项目与 gradle 文件同步。
推荐阅读
- airflow - 尝试在 Airflow 上使用 SendGrid 时出现错误 400(Google Composer)
- c++ - 无法编译 TRAP 库:'operator!=' 不匹配(操作数类型为 'std::basic_istream
' 和 'long int') - c# - 将数据表列附加到其他数据表
- processing - 处理 Keypress BACKSPACE 未被检测到
- android - 如何在我的java类中使用leakcanary.AppWatcher?
- javascript - 如何使用传单在地图上绘制连续线?
- office-js - 如何将functions.ts拆分成多个文件,仍然使用webpack插件CustomFunctionsMetadataPlugin
- python - 我想在单独的行上打印每个数字的平方
- c# - 如何通过转义键停止无休止的服务器线程
- python - 在嵌套字典列表中获取相同字典键的平均值