本文翻译自:Still getting warning : Configuration 'compile' is obsolete and has been replaced with 'implementation'
I have replaced every occurrence of compile
by implementation
in my project's build.gradle
, but I'm still getting this warning : 我已经在项目的build.gradle
中用implementation
替换了所有出现的compile
build.gradle
,但是仍然收到以下警告:
I tried to look for "compile " in the whole project but no match was found. 我试图在整个项目中寻找“编译”,但未找到匹配项。 So what could be the cause? 那是什么原因呢?
参考:https://stackoom.com/question/3INf4/仍在警告-配置-编译-已过时-并已由-实现-代替
https://issuetracker.google.com/issues/72479188 indicates that plugins sometimes can introduce "compile" dependencies and that's what triggers the warning. https://issuetracker.google.com/issues/72479188指示插件有时会引入“编译”依赖项,这就是触发警告的原因。 Probably just easiest to star that issue and wait until they fix it to point out which plugins are causing the issue. 也许最容易给该问题加注星标,然后等待他们修复它,以指出引起该问题的插件。
Reply by google : https://issuetracker.google.com/issues/74048134 谷歌回复: https : //issuetracker.google.com/issues/74048134
There would be some dependency still using compile, check your application dependencies and transitive dependencies carefully. 仍有一些依赖项仍在使用编译,请仔细检查您的应用程序依赖项和可传递依赖项。
I've updated com.google.gms:google-services
from 3.1.1
to 3.2.0
and the warning stopped appearing. 我已经将com.google.gms:google-services
从3.1.1
更新为3.2.0
,并且警告不再出现。
buildscript {
repositories {
google()
jcenter()
}
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'
}
}
No need to remove the line. 无需删除该行。 As Jkrevis wrote, update the com.google.gms:google-services to 3.2.0 and it stops the warnings. 正如Jkrevis所写,将com.google.gms:google-services更新为3.2.0并停止警告。
Open up your build.gradle file located here: 打开位于以下位置的build.gradle文件:
This is the old way of writing the dependency libraries (for gradle version 2 and below): 这是编写依赖库的旧方法(适用于gradle版本2和更低版本):
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile files('libs/volley.jar')
compile 'com.android.support:support-v4:21.+'
}
This is the new (right) way of importing the dependencies for gradle version 3: 这是为gradle版本3导入依赖关系的新(正确)方法:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation files('libs/volley.jar')
implementation 'com.android.support:support-v4:21.+'
}