Not able to create new color item in colors.xml file
AndroidXmlColorsAndroid Problem Overview
The error I am getting is : "The color "colorRed" in values has no declaration in the base values folder; this can lead to crashes when the resource is queried in a configuration that does not match this qualifier less... "
I have tried clean project and rebuild and also tried invalidate cache & restart but still that error not going.
I have attached screenshot of colors.xml file
Android Solutions
Solution 1 - Android
I solved the problem cleaning the project and build it again. If it doesn't work, invalidate caches and restart.
I'm using Android Studio 3.2
Invalidate Caches with File > Invalidate Caches / Restart... > Invalidate and Restart
Solution 2 - Android
Its a bug, and it happens for dimensions and possibly others. (Not just colours.) First time I saw it was the day I upgraded to AS 3.2.1.
But you may not need to clean, rebuild or invalidate caches. Try this:
(A) Cut and save (e.g. to NotePad) the flagged XML from the base folder and all qualified folders.
(B) Paste it back in, starting with the base folder
Update: 10Jan2019 [Dumb and dumber]
In fact, not even cutting and pasting is necessary. Suppose the following line is giving the problem...
<string name="edit">Edit</string>
Just change the tag to anything. e.g.
<xstring name="edit">Edit</string>
Then wait a second for removal to occur before changing it back
Solution 3 - Android
It's a weird bug. but here's a Workaround: Open the file in android studio and select all the text. now cut all the text and paste it in the same place. (or simply, go to the problematic file and press- 'ctrl+A' --> 'ctrl+x' --> 'ctrl+v') this does not change anything but apparently solves the errors.
Solution 4 - Android
This error occures still in AS3.4C10... so it is not solved yet.
For me, the only remedy is to select "Invalidate Cache/Restart" from File menu.
RG
Solution 5 - Android
I might be a bit late to the party, but the latest update of Android Studio (v3.2 Canary 17) seems to have solved this bug.
I had a similar issue with colors and resources and updating Studio seems to have fixed it.
Hope this helps!
Solution 6 - Android
I quit and restarted Studio and the error went away.
Solution 7 - Android
Open Resources->Add new Resource -> choise "New Color value.." other defend on you I using in android 3.3.1
Solution 8 - Android
I'm late to the party, but I fixed this problem by just altering the typing work. I added some more spaces to make it look cleaner and more readable and suddenly the red underline and error messages were gone. Must have been a bug of sorts. (Studio 3.3.3)
Solution 9 - Android
I had same error. I just ran the project with same condition and the error went away.
Solution 10 - Android
Did you paste it in from a spreadsheet? If so, just check that everything that looks like a double quote is in fact a double quote. Spreadsheets are a great way to build lengthy resource files, concatenating cells of xml formatting text around cells of names & items etc, but you might find that some of those cells you began with a double quote (e.g. ") will usually have a special open/close-quote character instead. These look like the real thing, but they won't be recognised as xml text indicators, so if e.g. your object name never gets initiated, you'll get this error.
Solution 11 - Android
In my case there was literally "no declaration in the base values folder" because the xml file wasn't in the base values folder, after selecting create new file, although the directory tree showed it to be in the values folder.
Find your xml file in the directory tree, select refactor, select move, and look at the path. If there's an invisible addition to the path, delete it back to the proper folder.
Solution 12 - Android
This is not an error. It is just an IDE bug.
Just run the project and the error will be automatically resolved.