Android Studio 3.2.1中的colors.xml问题 [英] Issue with colors.xml in Android Studio 3.2.1

查看:533
本文介绍了Android Studio 3.2.1中的colors.xml问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我尝试使用Android Studio 3.2.1创建Android项目时遇到的尴尬和不完整的colors.xml.

Following is the awkward and incomplete colors.xml I get while trying to create an Android project using Android Studio 3.2.1.

我得到的错误是D:\AndroidStudioWorkspace\PlayCardz\app\src\main\res\values\colors.xml:7:19: Error: XML document structures must start and end within the same entity.

为什么会这样?

更新

在将colors.xml文件手动更改为以下内容之后,我开始出现以下错误:

After manually changing colors.xml file to following I start getting the following error:

Android resource compilation failed
Output:  D:\AndroidStudioWorkspace\GameCardz\app\src\main\res\mipmap-anydpi-v26\ic_launcher_round.xml:1: error: not well-formed (invalid token).

Command: C:\Users\docrk\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\a0fab621f980e2e9b95746cdfd1fc60d\aapt2-3.2.1-4818971-windows\aapt2.exe compile --legacy \
        -o \
        D:\AndroidStudioWorkspace\GameCardz\app\build\intermediates\res\merged\debug \
        D:\AndroidStudioWorkspace\GameCardz\app\src\main\res\mipmap-anydpi-v26\ic_launcher_round.xml
Daemon:  AAPT2 aapt2-3.2.1-4818971-windows Daemon #0

手动更新的colors.xml文件:

Manually updated colors.xml file:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!--   color for the app bar and other primary UI elements -->
    <color name="colorPrimary">#3F51B5</color>

    <!--   a darker variant of the primary color, used for
           the status bar (on Android 5.0+) and contextual app bars -->
    <color name="colorPrimaryDark">#303F9F</color>

    <!--   a secondary color for controls like checkboxes and text fields -->
    <color name="colorAccent">#FF4081</color>
</resources>

推荐答案

此文件是从<Android Studio install dir>/plugins/android/lib/templates/gradle-projects/NewAndroidModule/root/res/values/colors.xml复制的.检查它是否在此文件中发现任何错误.

This file is copied from <Android Studio install dir>/plugins/android/lib/templates/gradle-projects/NewAndroidModule/root/res/values/colors.xml. Check for it to find any error in this file.

对我来说,此文件的内容是

For me, the content of this file is

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="colorPrimary">#008577</color>
    <color name="colorPrimaryDark">#00574B</color>
    <color name="colorAccent">#D81B60</color>
</resources>

如果修改了模板,则将其覆盖.

Overwrite it if your template is modified.

更新:有关更新的问题:我认为您的项目模板完全被混乱所覆盖.您可以通过找到文件路径的错误输出源来递归地找到模板的错误(例如,更新中的错误显示文件(D:\AndroidStudioWorkspace\GameCardz\app\src\main\res\mipmap-anydpi-v26\ic_launcher_round.xml,该错误可以映射到模板文件<Android Studio install dir>/plugins/android/lib/templates/gradle-projects/NewAndroidModule/root/res/mipmap-anydpi-v26/ic_launcher_round.xml中). ),请更正每一个.

Update for the updated question: I think your project template is totally overwritten with a mess. You may recursively find what the error of your templates are, by finding the source of error output of the file path (for example, the error in the update says file (D:\AndroidStudioWorkspace\GameCardz\app\src\main\res\mipmap-anydpi-v26\ic_launcher_round.xml, which can be mapped into the template file <Android Studio install dir>/plugins/android/lib/templates/gradle-projects/NewAndroidModule/root/res/mipmap-anydpi-v26/ic_launcher_round.xml.), correct each of them.

或者,因为此模板位于<Android Studio install dir>中(实际上是捆绑的插件),所以您可以重新安装Android Studio或重新安装(但如何?)该插件来解决此问题问题.

Or, since this template locates in <Android Studio install dir> (actually it is a bundled plugin), you may reinstall your Android Studio, or reinstall (but, how to?) that plugin to fix this issue.

这篇关于Android Studio 3.2.1中的colors.xml问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆