Solution :
I had faced this issue in the past. It is really tough issue to resolve if you don’t have any guidance. I can help you in resolving your error.
Please follow below procedure very carefully to fix your issue.
You need to go to your File->Invalidate Caches / Restart
After this you should clean the .gradle and .idea these directories are present under your project root directory.
Also you need to add the below given Google Maven repository and then you can sync your project
buildscript {
repositories {
jcenter()
google()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
}
Currently if you the Android Gradle Plugin 3.1.3 then you update it to version 4.4. Under your root directory of the project, you must update your gradle-wrapper.properties as follows.
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
Hope it fixed your issue.