代码之家  ›  专栏  ›  技术社区  ›  skip

Android Studio 3.2.1中的colors.xml版本

  •  0
  • skip  · 技术社区  · 6 年前

    以下是笨拙和不完整的 colors.xml 我尝试使用android studio 3.2.1创建一个android项目。

    enter image description here

    我得到的错误是 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文件更改为following之后,我开始获取以下错误:

    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文件:

    <?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>
    
    2 回复  |  直到 6 年前
        1
  •  1
  •   Geno Chen    6 年前

    此文件复制自 <Android Studio install dir>/plugins/android/lib/templates/gradle-projects/NewAndroidModule/root/res/values/colors.xml . 检查以查找此文件中的任何错误。

    对我来说,这个文件的内容是

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

    如果模板被修改,则覆盖它。

    更新 对于更新后的问题:我认为你的项目模板完全被一团糟覆盖了。通过查找文件路径的错误输出源(例如,更新says文件中的错误),可以递归地查找模板的错误。 (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 ,更正每个错误。

    或者,由于此模板位于 <Android Studio install dir> (实际上是一个捆绑插件),你 可以 重新安装Android Studio或重新安装(但如何安装?)修复此问题的插件。

        2
  •  0
  •   Tanveer Ahmed    6 年前

    在我的例子中,我不得不删除c\useres\username中的.gradle.android和.androidstudio3.x文件夹,结果又恢复了正常。我想你最近更新了AndroidStudio。