339

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?

A-Sharabiani
  • 13,270
  • 12
  • 87
  • 109
Rob
  • 3,770
  • 2
  • 23
  • 47
  • Are you using a local library that is using 'compile' still? – Devsil Feb 09 '18 at 16:30
  • @Devsil possibly... but how can I find out which one? I tried a Find in Path in the whole project but couldn't find any occurrence of `compile`.. – Rob Feb 12 '18 at 09:56
  • 2
    If you are using a local library you will see its gradle.build file located in the project viewer on the right side of your Android Studio window. In that build.gradle file it may contain a "compile" as opposed to implementation. If any build.gradle file you see there doesn't contain that. It may be a library you are using that isn't local thus not giving you access to change that. So this warning can just be ignore for now. – Devsil Feb 12 '18 at 13:28
  • 1
    Gradle should give the line number where the problem is occuring – Yetti99 Mar 31 '18 at 18:59
  • try it : https://stackoverflow.com/questions/48623244/error-configuration-compile-is-obsolete-and-has-been-replaced-with-implemen#answer-49595984 and for `Failed to resolve: android.arch.persistence.room:runtime:1.1.1 Open File Show in Project Structure dialog` try to change version to `1.0.0` – Saeid Apr 01 '18 at 16:36
  • Post your `build.gradle` files. – Jared Burrows Apr 01 '18 at 22:56
  • Possible duplicate of [Android Studio build.gradle warning message](https://stackoverflow.com/questions/48462550/android-studio-build-gradle-warning-message) – A-Sharabiani Apr 07 '18 at 19:36

23 Answers23

501

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'
    }
}
Rohit Sharma
  • 976
  • 4
  • 15
  • 32
Jkrevis
  • 5,052
  • 1
  • 5
  • 4
  • 1
    Configuration 'compile' is obsolete and has been replaced with 'implementation'. It will be removed at the end of 2018 To be clear am not using any google service dependencies { classpath 'com.android.tools.build:gradle:3.1.0' } – Amit_android Apr 04 '18 at 04:31
  • I get "Could not find com.google.gms:google-services:3.2.0." when I try this. Update: changing it manually triggered lint warning when I changed it back to 3.1.1, then Alt+Enter to apply fix automagically changed it to com.google.gms:google-services:3.2.0 with no errors on sync. I'm not sure what the difference was but it's frustrating. – jwehrle Apr 08 '18 at 21:18
  • Alright, I believe I understand the difference. I had changed the Project and Module build.gradle gms classpath to version 3.2.0. It's the Module change that caused the problem. Change only the Project build.gradle gms classpath version. – jwehrle Apr 08 '18 at 21:27
  • I was also missing jcenter() repo! The project was very old and did not have that repo included! – Yani2000 Apr 22 '18 at 16:53
  • Do you mean that I should just add that line manually to the file? – hellogoodnight Apr 22 '18 at 18:40
  • Done all as you said. Still getting same annoying warning – Vito Valov Apr 30 '18 at 08:28
  • This answer is very close to truth, but I had such an issue without having com.google.gms plugin whatsowever. So it probably should be state that you need to update all plugins you have and hopefully they all already have new versions. – EdgarK May 03 '18 at 08:35
  • warning gone!! Thanks – Md Nakibul Hassan Jun 25 '18 at 17:52
  • Worked for me, and with this I also had to change all play-services-*:8.4.0 to 9.0.0 – La Fortuna Dec 18 '18 at 18:35
  • yeah great, was very annoying issue, Thank you :) – Ramkesh Yadav Jan 25 '19 at 07:22
  • I have the newer version of play services and `jcenter()` as well is added already. And this does not seem to resolve the issue. – sud007 Feb 22 '19 at 07:05
126

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

Ali Khaki
  • 1,082
  • 1
  • 10
  • 22
Didier
  • 1,809
  • 1
  • 8
  • 9
  • Note that "testCompile" changes to "testImplementation". – AJW Aug 10 '18 at 03:05
  • most of the answers , and the most popular one as well , are all focusing on com.google.gms:google-services but it's all about updating the old naming style in both gradle files – kommradHomer Sep 09 '18 at 21:12
32

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'

    }
}
Prateek218
  • 634
  • 6
  • 21
  • you just need to change the version like I have this 'com.google.gms:google-services:3.2.0' you need to do just replace 3.2.0 with 3.2.1. – Prateek218 Jul 25 '18 at 10:03
  • Thanks, I had updated the wrong class, that's why I got the error. – Jhorra Jul 26 '18 at 00:51
  • 2
    I have the version `classpath 'com.google.gms:google-services:4.1.0'` not most updated but yeah, it is greater than `3.2.0`. No resolution still! – sud007 Feb 22 '19 at 07:10
  • @sud007 can you explain a bit what issue are you facing or post your build.gradle(Project level) – Prateek218 Feb 22 '19 at 11:39
23

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'
        ...  
    }
}
Hovanes Mosoyan
  • 742
  • 7
  • 9
18

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.+'
}
Gene
  • 9,441
  • 1
  • 60
  • 54
  • 1
    Thanks friend! This seems like the most up-to-date answer here as of January 2019 – NaturalBornCamper Jan 21 '19 at 04:33
  • This answer is helpful to those who are facing this issue for the first time. Although, OP has a different question, which says that even after those changes, error message is displayed. – sud007 Feb 22 '19 at 07:07
13

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.

quangkid
  • 1,067
  • 1
  • 10
  • 29
7

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.

Eric
  • 5,038
  • 6
  • 27
  • 33
6

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.

Tom
  • 61
  • 3
  • 1
    Did you replaced every occurrence of 'compile' by 'implementation' in your project's build.gradle(Module:App) and updated the com.google.gms:google-services in build.gradle(Project) to 3.2.0 ? – Tom Apr 09 '18 at 20:58
6

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.
zhangliang
  • 991
  • 7
  • 9
  • 2
    I think this is the general solution. The problem could be caused by any one, or several, of your dependencies – Rasmusob Dec 10 '18 at 12:26
5

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'
  }
}
ken
  • 1,406
  • 2
  • 25
  • 63
3

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.
Khemraj Sharma
  • 46,529
  • 18
  • 168
  • 182
2

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!

Haileapp
  • 688
  • 6
  • 18
2

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
}
RABI Hamza
  • 96
  • 8
2

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.

PerrierCitror
  • 1,671
  • 3
  • 16
  • 31
1

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.

tpn
  • 33
  • 4
1

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'
}

}

Frank Eno
  • 2,378
  • 2
  • 23
  • 41
0

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.
Unheilig
  • 15,690
  • 193
  • 65
  • 96
Jasbin Karki
  • 394
  • 5
  • 13
0

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.

  • Note that if you're using `classpath` you must use it inside a `buildscript` block; moreover, one cannot use `implementation` inside a `buildscript` block. – ChumiestBucket Jan 09 '19 at 00:07
0

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'
Jagadesha NH
  • 2,145
  • 2
  • 18
  • 33
0

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'
    }
Dr NVS
  • 73
  • 1
  • 5
-2

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

Thiyagu
  • 45
  • 1
  • 5
-3

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

Ujjwal Singh
  • 4,664
  • 3
  • 33
  • 50
-7

go to you build.gradle (app level)

build.gradle module app

and replace the word "compile" by "implementation"

it will work 100%

Ayoub
  • 377
  • 2
  • 7
  • 6
    This answer is not useful. The OP already stated that this was done, so it cannot possibly help. – NightOwl888 Apr 18 '18 at 01:20
  • 1
    i had the same issue, i couldn't generate my app apk bcoz of that, that answer solved my problem – Ayoub Apr 18 '18 at 12:52
  • This is not the same situation, OP already stated he's done this (I'm also in the same boat) it's due to dependancies – ElliotM Apr 27 '18 at 14:44
  • OP said "I have replaced every occurrence of compile by implementation". – mapo Jul 18 '18 at 19:55