ERROR: There can be only one Game target per project

I found the solution to this error. For me, it was caused by me renaming the project, which made it create duplicate .Build.cs, .cpp, .target.cs files under the new name.

I renamed everything back to the original names, then removed the duplicate .Build.cs, .cpp, .target.cs files that are located in the “source” folder (saved these just in case).

After that, it solved the problem.