Game works in editor; not builds; "GameObject has undefined tag"

I have been working on a chess game on Unity 5. It works correctly when testing, but after I build to web or exe, and run the game, every time I click a piece, the console spits out
“UnityException: GameObject has undefined tag!”

But I checked, all the pieces are tagged, and this is not an error that ever occurs when playing in development mode?

Anyone have any ideas on how to narrow down what’s causing this/how to fix? I’m very new to unity (this is only my second project) and would love to get this working.

I had the same problem and the solution by “Shinugami” solved it: UnityException: GameObject has undefined tag! Xcode console message - Unity Answers

I faced the same issue but on the Android , I fixed the issue by export the whole of the project and import it to other new project

I was seeing the same error message when running on Android, but not within the editor. The same logic error was occurring on iOS, but I haven’t checked the logs to see if this was the exact error message.

This particular project was upgraded from Unity 4 to Unity 5.6.1f1. What I found is that in Project Settings | Tags and Layers there were a few tags marked as “Removed”, and a message from Unity stating that they would actually be removed the next time the project was loaded. Unfortunately, reloading the project would never remove them.

My hunch was that Unity was in a state where it thought the tags were up to date, and that there was nothing to do to them at project load.

The answer was to add a temp Layer, save the project, then reload the project. I restarted Unity just to be safe. The “Removed” tags were then actually removed, and everything is now working properly on Android builds. I’ll test iOS as well, but I would bet money it’s fixed as well.

My assumption is that making a change (adding a layer) marked a dirty flag internally and Unity’s cleanup logic at project load now saw that there was a change to the Tags and Layers and did it’s normal processing. The tags probably got screwed up when upgrading the project from Unity 4 to Unity 5. That I don’t know. The tags look fine in Unity 4.

Afterwards, I did of course remove the temp layer.

I had a similar problem. It seemed to just be one function in the game that wasn’t working.

Turned out I had a bunch of empty scripts in my game on a prefab which was giving console errors. Was something I’d neglected to solve earlier. Don’t know how, but that solved it. Hope that helps.

Right mouse button in project → Reimport all