如何解决这个问题"Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'."
How to solve this "Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'."
当我尝试使用 GitHub 的问题时。我放弃
Configuration 'compile' is obsolete and has been replaced with
'implementation' and 'api'.
我尝试使用 Material 日历视图
My 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'
}
您可以更改此行 compile 'com.applandeo:material-calendar-view:1.5.1'
到这个implementation 'com.applandeo:material-calendar-view:1.5.1'
在后来的 gradle 版本中,compile
被 api
和 implementation
取代。
api
暴露了对外部模块的依赖,就像 compile
一样。所以如果你有模块 A
依赖于模块 B
而模块 B
依赖于 C
,如果 C
发生变化,那么 A
需要重新编译。 Gradle 团队认识到这在很多情况下是不必要的,因此它引入了 implementation
因此如果 C
更改仅依赖于它的模块将必须重新编译,这意味着只有模块 B
。这缩短了构建时间并使项目更加整洁。
简而言之,如果您将所有 compile
替换为 api
,结果将是相同的,这就是警告所针对的内容。
但是,根据经验,您希望尽可能使用 implementation
以避免依赖项污染项目。
我会尝试先用 implementation
替换 compile
并构建项目。
这个 link 对差异进行了更好的解释和可视化。
当我尝试使用 GitHub 的问题时。我放弃
Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
我尝试使用 Material 日历视图
My 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'
}
您可以更改此行 compile 'com.applandeo:material-calendar-view:1.5.1'
到这个implementation 'com.applandeo:material-calendar-view:1.5.1'
在后来的 gradle 版本中,compile
被 api
和 implementation
取代。
api
暴露了对外部模块的依赖,就像 compile
一样。所以如果你有模块 A
依赖于模块 B
而模块 B
依赖于 C
,如果 C
发生变化,那么 A
需要重新编译。 Gradle 团队认识到这在很多情况下是不必要的,因此它引入了 implementation
因此如果 C
更改仅依赖于它的模块将必须重新编译,这意味着只有模块 B
。这缩短了构建时间并使项目更加整洁。
简而言之,如果您将所有 compile
替换为 api
,结果将是相同的,这就是警告所针对的内容。
但是,根据经验,您希望尽可能使用 implementation
以避免依赖项污染项目。
我会尝试先用 implementation
替换 compile
并构建项目。
这个 link 对差异进行了更好的解释和可视化。