Ross Baghdatis, ranked No. 31 on the men's tour and a finalist at the 2006 Australian Open tennis tournament, also pulled out, citing a wrist injury.
Sharapova suffered the shoulder injury Wednesday during a second-round match against Marta Domachowska at the Rogers Cup in Montreal. Sharapova double faulted 17 times in the match.
"After yesterday's match I knew there was something seriously wrong with my shoulder," Sharapova said. "After taking a few different exams and MRIs this morning, the doctors found two small tears in the tendons of my shoulder.
"This is something that needs a lot of time to heal, which really hurts me to say that I have to miss the Olympics."
Sharapova has won three tournaments this year, including the Australian Open.
Baghdatis was the main Olympic medal chance for his native Cyprus. His coach, Yiannos Hadjigeorgiou, said Baghdatis would also miss the U.S. Open.
The tennis competition in Beijing will begin Aug. 10. The women's singles gold medal match will take place Aug. 16.
Celebrity Families of 2014 [PHOTOS]