Configuration compile is obsolete and has been replaced with implementati解决方案

转自:明哥l

今天把Android Studio更新到3.1.2编译之前的项目直接抛出下面的异常,这让我很是头疼,经过一翻查找发现是我们配置文件中的API已经过期,我对过期的API进行修改就Over了

1、异常展示

Configuration ‘compile’ is obsolete and has been replaced with ‘implementation’ and ‘api’.

2、解决方案

1.把compile 改成implementation
2.把androidTestCompile改成androidTestImplementation
3.把testCompile改成testImplementation

3、原未修改配置文件

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

4、已修改配置文件

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

总结

1. 亲测可行 解决了我的问题!

2.为什么转载?因为我看到有人解决了这个问题 竟然收费
19.9元 真的很气愤 难道写博客为了牟利吗?

3. 转载只为更多的人看到 浪费不必要的时间!

猜你喜欢

转载自blog.csdn.net/Life_s/article/details/106188866