The key to earning studs is to farm them. The best place I've found for this is on the Millenium Falcon, at the table with the Dejarik Battle. This is a horde mode type game. (I didn't notice this until after I finished the story, but it may be there sooner. The only videos I can find online seem to show the battle as unlocked after the story is finished, so you may need to go through all of those missions first.)
With no red bricks activated (no multipliers, no stud magnet), I made the following video where I earned 600,000 in one run. With multipliers on, I earned over 3 billion, easily enough to buy everything, and earn this challenge. BB-8 is key, since he can run fast enough to pick most of them up before they disappear.
Here are where the multiplier studs are:
2x - Chapter 4 - 1,000,000 studs
4x - Chapter 8 - 2,000,000
6x - Chapter 5 - 3,000,000
8x - Chapter 3 - 4,000,000
10x - Jakku - Lor San Tekka's Return - 5,000,000
*You can use BB-8 to jump down behind the Admiral Ackbar pool to reach this. Thanks to kintaris for pointing this out!