Follow the SO answer: http://stackoverflow.com/a/35859572/5539403
In Android Studio go to File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle
Check the ‘Offline work’ under ‘Global Gradle settings’
However, if it Gradle needs to get libraries from the Internet, turn off ‘Offline work’ and run it for first time, then turn the option on to speed up build process.