The match will take place in San Jose, before a fixture against Mexican side Chivas in Los Angeles on 31 July.
Manchester United, Everton, Chelsea and Tottenham are among other English sides to have played the All-Star XI.
"We are pleased to welcome Arsenal, one of the most successful clubs in the world, to compete against the best of MLS," said MLS commissioner Don Garber.
Arsenal will play a Major League Soccer All-Star team in a pre-season match in California on 28 July.