since thisThere is for an Arduino I just want to add a possibility toalso the list of answers herepossibility of the the controller itself being placed oppositelythe wrong way in the socket on the Arduino, this. This can be dangerous for the controller which(which may get zapped) but, in my case, it only gave the out of sync error and couldn't upload any codes, preventing me from uploading code.
So just check if the notch on the IC is in the right direction (you can cross check with images of board online, for example). The notch on the Uno's controller notch should point towards edge of board for Arduino Uno)
P.S. Thanks to the stupid Stack Exchange rule of low reps not being able to comment, but being able to answer that something this silly can be an answer.