Warning:Configuration 'compile' is obsolete and has been replaced with 'implementation'.

警告是这样的:

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

讲的是 :

**警告:配置' compile '已过时,已被' implementation '取代。将在2018年***去除掉这个**

解决办法:

例如我们以前的代码是这样的:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:support-core-ui:25.3.1'
    compile 'com.android.support:design:25.3.1'
    testCompile 'junit:junit:4.12'
}

改写后的代码:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:25.3.1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:support-core-ui:25.3.1'
    implementation 'com.android.support:design:25.3.1'
    testImplementation 'junit:junit:4.12'
}

改的原则:

compile  改成  implementation 
androidTestCompile  改成  androidTestImplementation 
testCompile  改成  testImplementation

总之就是把看到有compile  改成  implementation 就行了

对于他们两个的区别,其实我觉得区别不太大感觉就是Google把他优化了一下

compile与implemention 的区别

compile:可以传递依赖和引用,但是编译时间长于implementation

implementation:

不可传递依赖引用,比如B依赖A,C依赖B,但是C却不能依赖A。所以编译时间更短。

但是对于他们的用处还是一样的,没有做什么改变,对于api代替compile,他们功能相同。

猜你喜欢

转载自blog.csdn.net/z1web/article/details/84374953