63

After i have successfully updated to Android Studio 3.1 Canary 9 i am getting warning message as

Warning:Configuration 'compile' is obsolete and has been replaced with 'implementation'.
It will be removed at the end of 2018

I know this warning will not cause any problem in my project at least for now. But i want to remove it totally so that there will be no problem in future at all. But after reviewing my build.gradle file i cannot find any line of code which has invoked this warning at all.

Here is my build.gradle file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "app.project.virtualdiary"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation 'com.google.firebase:firebase-auth:11.8.0'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.0.2'
    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'
    implementation 'com.android.support:support-v4:27.0.2'
    implementation 'com.android.support:support-vector-drawable:27.0.2'
}


apply plugin: 'com.google.gms.google-services'
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245

6 Answers6

76

The problem lies in apply plugin: 'com.google.gms.google-services'

The Google Services plugin is adding a dependency on behalf of you. Hopefully they fix it in the future.

Niklas
  • 23,674
  • 33
  • 131
  • 170
44

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

Good luck

Didier
  • 1,809
  • 1
  • 10
  • 9
  • 1
    I've tried changing to com.google.gms:google-services:3.2.0, but the warning still appears – flyingAssistant Apr 03 '18 at 11:29
  • **If you changed all the dependencies of complie to implementation.** The problem is that you can be external dependencies. Google has change complile to implementation in the com.google.gms version: google-services: 3.2.0 but other dependencies may not be up-to-date. you can try to update the other dependencies to see if in the new version we fix the problem. – Didier Apr 04 '18 at 07:15
6

I agree with Niklas. I changed the compile to implementation, but the warning was gone only after the change in the build.gradle(Project: .....)

before:

 dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'
        classpath 'com.google.gms:google-services:3.0.0'
    }

after:

dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'
        classpath 'com.google.gms:google-services:3.2.0'
    }
SportAtomDroid
  • 389
  • 3
  • 10
5

first select :

  1. Build
  2. Clean Project then Build
  3. make Project in Android studio
Nawrez
  • 3,314
  • 8
  • 28
  • 42
soheil pakgohar
  • 164
  • 2
  • 2
-2

When AndroidManifest.xml package name was different from build.gradle package name i get this error

Configuration 'compile' is obsolete and has been replaced with 'implementation'. It will be removed at the end of 2018

Java compile error

ethemsulan
  • 2,241
  • 27
  • 19
  • Depends on what you are targeting, but you are right, from the end of this month we must target 26> and in 26> `compile` is deprecated. But this is not the issue of this question. – HB. Jul 21 '18 at 13:55
-4

Change the "compile" to "implementation". this problem will be fixed! it works on my computer.

Hui Pang
  • 17
  • 1
  • In the above examples all the "dependency" has already been changed to "implementation" I guess that's why this has been downvoted. I overlooked it in the above parts so this comment did help me. – FrankKrumnow Apr 06 '18 at 11:35
  • read the question carefully! – Amir Dora. Jun 19 '18 at 11:06
  • Depends on what you are targeting, but from the end of this month we must target 26> and in 26> `compile` is deprecated. But this is not the issue of this question. – HB. Jul 21 '18 at 13:56