Following is the build.gradle code in Android Studio
apply plugin: \'com.android.application\'
android {
    compileSdkVersion 23
    buildToolsVersion \"23         
        I also encountered this error when updating to 'com.android.tools.build:gradle:3.0.0'
To fix it, I had to add the google() repo to both the buildscript and module repositories. The documentation here only mentions adding to to the buildscript.
Project-level build.gradle
buildscript {
    repositories {
        ...
        // You need to add the following repository to download the
        // new plugin.
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
    }
}
App-level build.gradle
repositories {
    ...
    // Documentation doesn't specify this, but it must be added here
    google()
}
gradle-wrapper.properties
...
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
                                                                        The only thing that helped me was to use the system gradle instead of Android Studio's built-in:
SETTINGS -> Build, Execution, Deployment -> Gradle
Select Use local gradle distribution. To find the path, you can do which gradle where the which program is supported. It might be /usr/bin/gradle.
See also Error:Could not initialize class com.android.sdklib.repositoryv2.AndroidSdkHandler for another possible cause.
First Step:File → Settings → Build, Execution, Deployment → Instant Run and uncheck Enable Instant Run. Second step: Press Invalidate/Restart. done.... Enjoy.
I am facing same error before a week I solve by disabling the Instant Run
File → Settings → Build, Execution, Deployment → Instant Run and uncheck Enable Instant Run.
Hope it works.
Note This answer works on below Android Studio 3
The problem is probably you're using a Gradle version rather than 3. go to gradle/wrapper/gradle-wrapper.properties and change the last line to this:
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
                                                                        I had this issue because I was using Charles proxy on my computer and the SSL was enabled for all hosts. And since AS didn't trust my proxy, the network request failed. So I had to disable SSL for all hosts and restart my Android Studio.