colors.xml: Error: Unsupported type 'component' (Android studio)

后端 未结 5 854
天涯浪人
天涯浪人 2020-12-22 02:17

After the creation of a new project, I get an error with the colors.xml file (more details here: Error on first build after creating a project: XML document structures must

相关标签:
5条回答
  • 2020-12-22 02:47

    There is no Component tag in a Color resource file.

    Here is an example of colors.xml

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <color name="colorPrimary">#3F51B5</color>
        <color name="colorPrimaryDark">#303F9F</color>
        <color name="colorAccent">#FF4081</color>
    </resources>
    
    0 讨论(0)
  • 2020-12-22 02:54
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    <color name="colorPrimary">#79302a</color>
    <color name="colorPrimaryDark">#561e1c</color>
    <color name="colorAccent">#345f41</color>
    </resources>
    

    This is what a colors.xml looks like. See if it works for you

    0 讨论(0)
  • 2020-12-22 03:00

    I had the same error, but also something similar in several files of the project every time i open a new project. I followed something that someone (can't remember the name) answer in another question:

    1.- go to your user folder -->androidStudio folder --> System folder 2.- delete the caches folder

    After that the error haven't came back. Hope this help someone else.

    0 讨论(0)
  • 2020-12-22 03:03

    Ohh I too faced similar problems after upgrading studio to 3.2.1

    many issues from different files while creating new project:

    1. colors.xml

    2. ic_launcher_round.xml - mipmap

    3. ic_launcher_background.xml - drawable

    I tried to change these but nothing worked, changing one is causing other issue.

    Finally i have uninstalled 3.2.1 studio version and downloaded 3.1.4(android-studio-ide-173.4907809-windows.exe (828632688 bytes)) from here https://developer.android.com/studio/archive

    and finally everything worked fine. Still i don't know is this an issue from 3.2.1 studio version.

    Note: It's basically downgrading studio version :) worked for me.

    0 讨论(0)
  • 2020-12-22 03:13

    It may be which browser you got the install file from.

    I just had a student with the same problem (version 3.3 now), and it appears to have been fixed by having him install from a file downloaded with Chrome rather than with Edge. Did you originally install with an install file obtained using Edge?

    0 讨论(0)
提交回复
热议问题