在我的项目构建中,我已经替换了每一个compile by implementation的出现。gradle,但是我仍然得到这个警告:

我试图在整个项目中寻找“compile”,但没有找到匹配。那么原因是什么呢?


当前回答

只需从构建中添加。从构建脚本Gradle

classpath 'com.google.gms:google-services:3.2.0'

所有依赖项“compile”替换为“implementation”。

这对我很管用。

其他回答

回到你的位置。在项目级别的Gradle文件中,您会发现以下行突出显示

dependencies {
    classpath 'com.android.tools.build:gradle:3.1.4'  //place your cursor over here 
    //and hit alt+enter and it will show you the appropriate version to select


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files

    classpath 'com.google.gms:google-services:4.0.2' //the same as previously
}

你有两种选择:

在project: build中添加类路径'com.google.gms:google-services:3.2.0'。gradle依赖性 而且 替换模块:build。Gradle依赖于编译实现 而且你不会收到任何警告信息。

谷歌于2021年9月更新了其服务。给更新,我面临同样的问题,然后我更新构建。android studio中的Gradle文件

旧版本有问题

 classpath 'com.google.gms:google-services:4.3.3'

更新了build.gradle中的代码

classpath 'com.google.gms:google-services:4.3.10'

我在没有使用com.google.gms:google-services的情况下遇到了这个问题。 解决这类问题的方案如下:

检查构建。所有项目和模块的Gradle文件。或者只是全局搜索关键字“编译”,以找到引起此警告的原因。 如果上述方法无法解决此警告,则使用CLI命令, ./gradlew assembleDebug -d > gradle.log 打印详细的调试信息到一个名为gradle.log的文件或其他文件中,因为信息太多了。然后搜索“WARNING”在gradle.log中找到警告的位置,通常你可以找到哪个依赖或插件导致了警告。

我已经更新了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")
    }
}