简体   繁体   English

如何解决此问题“配置'compile'已过时,并已由'implementation'和'api'代替。”

[英]How to solve this “Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.”

When I try use issue from GitHub. 当我尝试使用来自GitHub的问题时。 I give in out 我让步

Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'. 配置“编译”已过时,已被“实现”和“ api”替换。

I try use Material Calendar View 我尝试使用材料日历视图

My gradle: 我的gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'
    defaultConfig {
        applicationId "com.mederov.timelord"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}



dependencies {
    compile 'com.applandeo:material-calendar-view:1.5.1'
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:support-v4:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.github.bumptech.glide:glide:4.4.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'
    implementation 'de.hdodenhof:circleimageview:3.0.0'

}

You can change this line compile 'com.applandeo:material-calendar-view:1.5.1' 您可以更改此行, compile 'com.applandeo:material-calendar-view:1.5.1'

to this implementation 'com.applandeo:material-calendar-view:1.5.1' implementation 'com.applandeo:material-calendar-view:1.5.1'

In the later gradle versions compile was replaced with both api and implementation . 在后来的gradle版本中, compileapiimplementation所取代。

api exposes the dependencies to external modules, just like compile does. apicompile一样将依赖项公开给外部模块。 So if you have module A depends on module B which depends on C , if C changes, then A needs to be recompiled. 因此,如果您的模块A依赖于模块B ,而模块B依赖于C ,则如果C更改,则需要重新编译A The Gradle team recognized this was unnecessary in a lot of cases, so it introduced implementation so if C changes only modules that depend on it will have to recompile, which means only module B . Gradle团队认识到在很多情况下这是不必要的,因此它引入了implementation因此,如果C仅更改依赖于它的模块,则必须重新编译,这意味着仅模块B This shortens build times and makes the project much more tidy. 这缩短了构建时间,并使项目更加整洁。

In short, if you replace all compile with api the result will be the same and that's what the warning is hitting at. 简而言之,如果将所有compile替换为api ,结果将相同,这就是警告的内容。

However, as a rule of thumb you'd want to use implementation whenever possible to avoid polluting the project with dependencies. 但是,作为经验法则,您希望在任何可能的地方都使用implementation以避免对依赖项造成污染。

I'd try to first replace compile with implementation and build the project. 我会尝试先用implementation代替compile并构建项目。

This link has a much better explanation and visualization of the differences. 链接可以更好地说明和显示差异。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 信息:配置“编译”已过时,已替换为“实施”和“API” - INFO: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api' 像配置“编译”这样的android studio中的同步依赖项错误已过时,已由“实现”和“ api”替换 - Error in syncing dependency in android studio like Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api' 信息:API 'variant.getMergeResources()' 已过时并已替换为 'variant.getMergeResourcesProvider()' - INFO: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()' API 'variant.getMergeResources()' 已过时并已替换为 'variant.getMergeResourcesProvider()' - API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()' Gradle:解决后无法更改配置“:compile”的依赖项 - Gradle: Cannot change dependencies of configuration ':compile' after it has been resolved 解决后无法更改配置“:compile”的依赖项 - Cannot change dependencies of configuration ':compile' after it has been resolved 如何在舞台中替换场景后获取场景的正确位置? - How to get the correct location of a Scene after it has been replaced in the Stage? 如何解决Maven Invoker API警告:Maven将以交互模式执行,但没有配置输入流 - How to solve Maven Invoker API warning: Maven will be executed in interactive mode, but no input stream has been configured 为什么 javax.persistence-api 在 spring data jpa starter 中被 jakarta.persistence-api 取代了? - Why has javax.persistence-api been replaced by jakarta.persistence-api in spring data jpa starter? 我的 Eclipse 插件没有找到 JAXB-API 的实现 - Implementation of JAXB-API has not been found by my Eclipse plugin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM