100% Solution. Just turn off the Toggle Offline Mode .
On the top right side of the Window .
Click on Gradle
2nd number option(just near of Setting option)
click on it then you will be able to do work continue sally.
As you can see the image
In The Right Side of the Android Studio, You can See Gradle option just click it and you will see a screen which is given below.
Gradle can be offline. If offline, you should do it online.
I had this problem also. Tried all the suggestions, but didnt help. The problem was in offline/online mode as other stated but you have to also check the compiler settings. Make sure there is no –offline flag
Preferences -> Build, Execution, Deployment -> Compiler
( Menubar ‘File’ button, ‘Settings’ menu option, ‘Build, Execution, Deployment’ menu twisty, ‘Compiler’ submenu )
On Command-line Options: –stacktrace