I got this error after an update of Android Gradle plugin and Android Studio.
I have checked this question (Android Studio build.gradle warning message), but I am not ab
Explaination:
since the compile is been obsolete in 2018 you must change this configuration as follows: 1. open build.gradle(module:app) app file and make following changes in it. 2. replace compile with api wherever api ref. like: volley, GitHub dependancy.strong text is used and 3. replace compile with implementation incase of using android libraries like play-services-maps,appcompat-v7 etc.
example: old way
dependencies {
testCompile'junit:junit:4.12'
compile 'com.android.volley:volley:1.1.0'
Change it to:
dependencies {
testImplementation 'junit:junit:4.12'
implementation 'com.android.volley:volley:1.1.0'
if the issue still persists:
open build.gradle (Project: yourproject) file and change the google gms services to the latest
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Also if the gradle sync is still failing:
Open gradle-wrapper.properties file and replace it with following:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Look at your dependencies in your build.gradle. anywhere you have compile, change to implementation. For example:
dependencies {
compile 'com.android.support:support-v4:27.0.3'
}
Should be:
dependencies {
implementation 'com.android.support:support-v4:27.0.3'
}
Step by Step solution
1- Go to the build.gradle(module app)
2- In the dependencies, you will see the code like this
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:design:23.3.0'
3- Now you have to ONLY replace the compile with implementation and testCompile with testImplementation. Like this
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:23.3.0'
implementation 'com.android.support:support-v4:23.3.0'
implementation 'com.android.support:design:23.3.0'
4- That's all. Now click on Sync Now button.
Note- Don't change the number or version given specified in the code.
just go to your app>> "Gradle Scripts" and open build.gradle(Project:"your project name") and change this line (classpath 'com.google.gms:google-services:3.1.0') to (classpath 'com.google.gms:google-services:3.2.0'). current version 4.0.1
Here is the complete solution:
steps
1) Use the new dependency configurations in gradle file Replace compile with an implementation For ex:
dependencies {
compile 'com.android.support:support-v4:27.0.3'
}
Should be:
dependencies {
implementation 'com.android.support:support-v4:27.0.3'
}
b) Replace testCompile
with testImplementation
For ex:
testCompile 'junit:junit:4.12'
should be
testImplementation 'junit:junit:4.12'
c) For library replace compile
with api
2) Upgrade classpath com.google.gms:google-services to classpath 'com.google.gms:google-services:3.2.0' in file in build.gradle (Use latest one)
3) File -> Invalidate Cache
Still Not Working: Then try below steps
1) Close the project.
2) Delete .gradle folder.
3) Open again the project
Now it will works