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."
Up next: Buster Posey is expected to start at catcher in Monday's exhibition against the Chicago White Sox, combining with left-hander Madison Bumgarner to form the Giants' battery. Posey did not travel to Mesa on Sunday, though he stayed active by working out at the Giants' Scottsdale Stadium complex. The National League's reigning Most Valuable Player performed for just three innings and flied out to medium-deep right field in his lone at-bat in Saturday's Cactus League opener against the Angels.