Still getting warning : Configuration 'compile' is obsolete and has been replaced with 'implementation'

AndroidGradleBuild

Android Problem Overview


I have replaced every occurrence of compile by implementation in my project's build.gradle, but I'm still getting this warning :

enter image description here

I tried to look for "compile " in the whole project but no match was found. So what could be the cause?

Android Solutions


Solution 1 - Android

I've updated com.google.gms:google-services from 3.1.1 to 3.2.0 and the warning stopped appearing.

buildscript {

	repositories {
		google()
		jcenter()
	}
	dependencies {
		classpath 'com.android.tools.build:gradle:3.1.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
	
    classpath 'com.google.gms:google-services:3.2.0'
	}
}

Solution 2 - Android

I have one same Warning caused to com.google.gms:google-services.

The solution is to upgrade classpath com.google.gms:google-services to classpath 'com.google.gms:google-services:3.2.0' in file in build.gradle Project:

enter image description here

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.2.0'
    }
}

allprojects {
    repositories {
        jcenter()
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

In Android Studio verion 3.1 dependencies complie word is replaced to implementation

dependencies with Warning in android studio 3.1

dependencies {
            compile fileTree(dir: 'libs', include: ['*.jar'])
            compile 'com.android.support:appcompat-v7:27.1.0'
            compile 'com.android.support.constraint:constraint-layout:1.0.2'
            testImplementation 'junit:junit:4.12'
            androidTestImplementation 'com.android.support.test:runner:1.0.1'
            androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    }
    

dependencies OK in android studio 3.1

    dependencies {
            implementation fileTree(dir: 'libs', include: ['*.jar'])
            implementation 'com.android.support:appcompat-v7:27.1.0'
            implementation 'com.android.support.constraint:constraint-layout:1.0.2'
            testImplementation 'junit:junit:4.12'
            androidTestImplementation 'com.android.support.test:runner:1.0.1'
            androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    
    }

Gradel generate by Android Studio 3.1 for new project.

Gradel generate by Android Studio 3.1 for new project.

Visit https://docs.gradle.org/current/userguide/dependency_management_for_java_projects.html

For details https://docs.gradle.org/current/userguide/declaring_dependencies.html

Solution 3 - Android

I've updated com.google.gms:google-services from 3.2.0 to 3.2.1 and the warning stopped appearing.

 buildscript {
    
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.1'
        classpath 'com.google.gms:google-services:3.2.1'

    }
}

Solution 4 - Android

Using the currently latest version of the google gms services resolved it for me.

In the project level build.gradle:

buildscript {
    ...
    dependencies {
        classpath 'com.google.gms:google-services:3.2.1'
        ...  
    }
}

Solution 5 - Android

Open up your build.gradle file located here:

enter image description here

This is the old way of writing the dependency libraries (for gradle version 2 and below):

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile files('libs/volley.jar')
    compile 'com.android.support:support-v4:21.+'
}

This is the new (right) way of importing the dependencies for gradle version 3:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    testImplementation 'junit:junit:4.12'
    implementation files('libs/volley.jar')
    implementation 'com.android.support:support-v4:21.+'
}

Solution 6 - Android

Reply by google : https://issuetracker.google.com/issues/74048134

There would be some dependency still using compile, check your application dependencies and transitive dependencies carefully.

Solution 7 - Android

https://issuetracker.google.com/issues/72479188 indicates that plugins sometimes can introduce "compile" dependencies and that's what triggers the warning. Probably just easiest to star that issue and wait until they fix it to point out which plugins are causing the issue.

Solution 8 - Android

No need to remove the line. As Jkrevis wrote, update the com.google.gms:google-services to 3.2.0 and it stops the warnings.

Solution 9 - Android

In my case,it is cause by Realm library,after I update it to latest version(5.1.0 so far) of Realm,the problem solved!

Here is the working gradle script:

buildscript {
repositories {
    jcenter()
    google()
}

dependencies {
    classpath 'com.android.tools.build:gradle:3.1.2'
    classpath "io.realm:realm-gradle-plugin:5.1.0"
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    classpath 'com.google.gms:google-services:3.2.1'
  }
}

Solution 10 - Android

I encounter this problem without using com.google.gms:google-services. The solution solving this kind problem as below:

  1. check build.gradle files of all projects and modules. Or just global search key word 'compile' to find where cause this warning.
  2. if above method cannot solve this warning, then use CLI Command,
./gradlew assembleDebug -d > gradle.log

print detail debug information to a file named gradle.log or any else, as the information is too much. Then search word "WARNING" to find the position in gradle.log, usually you can find what dependence or plugin cause the warning.

Solution 11 - Android

Just updating google-service version did not work for me.

  • First make sure all your dependencies compile are replaced with implementation.
  • Update all dependencies in your project. Because if one of your dependency is having compile then your project will show this error. So update all dependencies version.

Solution 12 - Android

I have tried changing the google gms services to the latest com.google.gms:google-services:3.2.1 in Android Studio 3.0.1 but the warning still persists.

As recommended by the compiler,I changed all compile dependencies to implementation and testCompile to testImplementation like this..

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:mediarouter-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.google.firebase:firebase-ads:12.0.1'
implementation 'com.google.firebase:firebase-crash:12.0.1'
implementation 'com.google.firebase:firebase-core:12.0.1'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
implementation 'com.google.firebase:firebase-perf:12.0.1'
implementation 'com.google.firebase:firebase-appindexing:12.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

And finally the warning is removed!

Solution 13 - Android

go to your build.gradle file in project level you will find the following lines highlighted

dependencies {
    classpath 'com.android.tools.build:gradle:3.1.4'  //place your cursor over here 
    //and hit alt+enter and it will show you the appropriate version to select
    

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files

    classpath 'com.google.gms:google-services:4.0.2' //the same as previously
}

Solution 14 - Android

In my case it was an old dependency that was using compile for the transitive dependencies : com.jakewharton.hugo

After removing it from my gradle it compiled.

Solution 15 - Android

The workaround to solve this problem was for me that I used an older version of Gradle, which can be found here:

I used the gradle-3.0-rc-1-src version, but others may work too, although probably it should not be newer than the 3.0-version.

First extract the zip file to anywhere you like.

Then go to File -> Settings -> Build, Execution, Deployment -> Gradle and change the setting to Use local gradle distribution. After that make sure that the Gradle Home-field is pointing to the .gradle directory in the directory you just unzipped to.

Rebuild the project and everything should be ok.

Solution 16 - Android

The current version is 4.2.0:

buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.4.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    classpath 'com.google.gms:google-services:4.2.0'
}

}

Solution 17 - Android

Google updated it's services recently in September 2021. Gave update and I faced same issue then I update the build.gradle file in android studio

Old version with issue

 classpath 'com.google.gms:google-services:4.3.3'

Updated code in build.gradle

classpath 'com.google.gms:google-services:4.3.10'

Solution 18 - Android

You can do this two options:

  1. Add classpath 'com.google.gms:google-services:3.2.0' in ur project: build.gradle dependencies and
  2. Replace your module: build.gradle in dependency from complile with implementation and you wont get any warning messages.

Solution 19 - Android

Just add from build.gradle from build script

classpath 'com.google.gms:google-services:3.2.0'

and all of the dependencies "compile" replace to "implementation".

that worked from me.

Solution 20 - Android

For me changing compile to implementation fixed it

Before

compile 'androidx.recyclerview:recyclerview:1.0.0'
compile 'androidx.cardview:cardview:1.0.0'
//Retrofit Dependencies
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'

After

implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
//Retrofit Dependencies
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'

Solution 21 - Android

I treid all the solutions mentioned here, but no luck. I found in my build.gradle file as below:

dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
    }

I just changed it as below and saved and tried build success.

dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
    }

Solution 22 - Android

Hope that you're affected with build.gradle(app) If do so , follow this step

Replace compile with androidTestImplementation in build.gradle

androidTestImplementation 'com.android.support:appcompat-v7:27.1.1'
androidTestImplementation 'com.android.support:design:27.1.1'

so simple ! hope this will solve

Solution 23 - Android

In my case the issue was the Google services gradle plugin with the following line in the gradle file:

> apply plugin: 'com.google.gms.google-services'

Removing this resolved the issue

Solution 24 - Android

go to you build.gradle (app level)

build.gradle module app

and replace the word "compile" by "implementation"

it will work 100%

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRobView Question on Stackoverflow
Solution 1 - AndroidJkrevisView Answer on Stackoverflow
Solution 2 - AndroidDidierView Answer on Stackoverflow
Solution 3 - AndroidPrateek218View Answer on Stackoverflow
Solution 4 - AndroidHovanes MosoyanView Answer on Stackoverflow
Solution 5 - AndroidGeneView Answer on Stackoverflow
Solution 6 - AndroidquangkidView Answer on Stackoverflow
Solution 7 - AndroidEricView Answer on Stackoverflow
Solution 8 - AndroidTomView Answer on Stackoverflow
Solution 9 - AndroidkenView Answer on Stackoverflow
Solution 10 - AndroidzhangliangView Answer on Stackoverflow
Solution 11 - AndroidKhemraj SharmaView Answer on Stackoverflow
Solution 12 - AndroidHaileappView Answer on Stackoverflow
Solution 13 - AndroidRABI HamzaView Answer on Stackoverflow
Solution 14 - AndroidPerrierCitrorView Answer on Stackoverflow
Solution 15 - AndroidtpnView Answer on Stackoverflow
Solution 16 - AndroidFrank EnoView Answer on Stackoverflow
Solution 17 - AndroidMuhammad MuzamilView Answer on Stackoverflow
Solution 18 - AndroidJasbin KarkiView Answer on Stackoverflow
Solution 19 - AndroidOmae wa mou shindairuView Answer on Stackoverflow
Solution 20 - AndroidJagadesha NHView Answer on Stackoverflow
Solution 21 - AndroidDr NVSView Answer on Stackoverflow
Solution 22 - AndroidThiyaguView Answer on Stackoverflow
Solution 23 - AndroidUjjwal SinghView Answer on Stackoverflow
Solution 24 - AndroidAyoubView Answer on Stackoverflow