Error Junit:Junit:4.12 not found or missing after Android Studio 1.4 to 1.5 update

After I updated Android Studio from 1.4 to 1.5, all went well and the patch got applied. However, when starting the project, I got an error that read something like this.
Error Junit:Junit:4.12 not found or missing

This error occurred due to gradle not getting updated / synced properly. Apparently, to speed up Android Studio, I had checked the Offline Work checkbox as in this post.

To fix the error, uncheck the Offline Work checkbox, apply the change and restart Android Studio. You will notice that gradle then syncs. Once the sync is complete you can go back and check the box once more, or just continue working. The JUnit error will no longer appear.