The declared package does not match the expected package “”

Try closing and re-opening the file.

It is possible to get this error in eclipse when there is absolutely nothing wrong with the file location or package declaration. Try that before spending a lot of time trying these other solutions. Sometimes eclipse just gets confused. It’s worked for me on a number of occasions. I credit the idea to Joshua Goldberg.

Leave a Comment