Alfonso Soriano lined a single off Cain's leg in the first. Soriano's hit loaded the bases with one out, and Nate Schierholtz then grounded out to first, driving in a run. Dioner Navarro followed with a three-run homer to open a 4-0 lead. Cain was pulled after the one inning.
"It's part of the game. You hope you get out of the way," said Cain, who was not expected to miss his next outing.
Francisco Peguero doubled with two outs in the Giants' first and scored on Guillermo Quiroz's single off Samardzija. Pablo Sandoval hit an RBI double in the third and Quiroz added a sacrifice fly in the fourth to make it 4-3.
Samardzija was able to work his fastball and split but called his slider "garbage." He'll try to get a feel for that in his next start.
"The slider last year was key for me," said the right-hander, who is entering his second full season as a starter. "To be pulling it in and leaving it up high was unfortunate but it's first time out. It's a big pitch for me."
He also showed his quick reflexes, dodging a shot from Quiroz in the second. Teammate Darwin Barney hit a comebacker at Samardzija during a live batting-practice session at Fitch Park before games began.
"Both of them were about as close as they get," Samardzija said. "I got out of there in proper time. Apparently, the coaches in Spring Training said, 'Stay up the middle' with these hitters. Cain took a couple up the middle and I did, too. It's part of the fun. You have to be on your toes and ready to go."
Samardzija did field a hard-hit comebacker by Kensuke Tanaka in the first. Navarro went out to talk to his pitcher after Quiroz's single nearly clipped Samardzija.
"After the second time, I went out there and asked him where the magnet was," Navarro said.
Up next: Carlos Villanueva will make his Cubs debut Monday when the team travels to Glendale to face the Dodgers. Villanueva is projected for the Cubs' bullpen but may start depending on the health of Matt Garza and Scott Baker. Also slated to make the trip are Luis Valbuena, Nate Schierholtz, Junior Lake and Welington Castillo. The game will be broadcast on Cubs.com.