ChatGPT解决这个技术问题 Extra ChatGPT

仍然收到警告:配置“编译”已过时并已替换为“实施”

我已在项目的 build.gradle 中将每次出现的 compile 替换为 implementation,但我仍然收到此警告:

https://i.stack.imgur.com/rXimx.png

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

您是否仍在使用仍在使用“编译”的本地库?
@Devsil 可能......但我怎样才能找出哪一个?我在整个项目中尝试了在路径中查找,但找不到任何出现的 compile..
如果您使用的是本地库,您将在 Android Studio 窗口右侧的项目查看器中看到其 gradle.build 文件。在那个 build.gradle 文件中,它可能包含一个“编译”而不是实现。如果您看到的任何 build.gradle 文件都不包含该文件。它可能是您正在使用的非本地库,因此无法让您访问更改它。所以这个警告现在可以忽略。
Gradle 应该给出出现问题的行号
试试看:stackoverflow.com/questions/48623244/…Failed to resolve: android.arch.persistence.room:runtime:1.1.1 Open File Show in Project Structure dialog 尝试将版本更改为 1.0.0

R
Rohit Sharma

我已将 com.google.gms:google-services3.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'
    }
}

配置“编译”已过时,已替换为“实现”。它将在 2018 年底被删除要明确我没有使用任何谷歌服务依赖项 { classpath 'com.android.tools.build:gradle:3.1.0' }
我收到“找不到 com.google.gms:google-services:3.2.0”。当我尝试这个时。更新:当我将其更改回 3.1.1 时,手动更改它会触发 lint 警告,然后 Alt+Enter 应用修复自动将其更改为 com.google.gms:google-services:3.2.0,同步时没有错误。我不确定有什么区别,但这令人沮丧。
好吧,我相信我理解其中的区别。我已将 Project 和 Module build.gradle gms 类路径更改为 3.2.0 版。这是导致问题的模块更改。仅更改 Project build.gradle gms 类路径版本。
我也错过了 jcenter() 回购!该项目非常旧,并且没有包含该回购!
你的意思是我应该手动将该行添加到文件中吗?
A
Ali Khaki

我对 com.google.gms:google-services 也有同样的警告。

解决方案是在 build.gradle 项目的文件中将 classpath com.google.gms:google-services 升级为 classpath 'com.google.gms:google-services:3.2.0':

https://i.stack.imgur.com/N9S5z.png

buildscript {
    repositories {
        jcenter()
        google()
    }
    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'
    }
}

allprojects {
    repositories {
        jcenter()
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

在 Android Studio 版本 3.1 中,依赖项 complie 字被替换为 implementation

android studio 3.1 中带有警告的依赖项

dependencies {
            compile fileTree(dir: 'libs', include: ['*.jar'])
            compile 'com.android.support:appcompat-v7:27.1.0'
            compile 'com.android.support.constraint:constraint-layout:1.0.2'
            testImplementation 'junit:junit:4.12'
            androidTestImplementation 'com.android.support.test:runner:1.0.1'
            androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    }

android studio 3.1 中的依赖关系OK

    dependencies {
            implementation fileTree(dir: 'libs', include: ['*.jar'])
            implementation 'com.android.support:appcompat-v7:27.1.0'
            implementation 'com.android.support.constraint:constraint-layout:1.0.2'
            testImplementation 'junit:junit:4.12'
            androidTestImplementation 'com.android.support.test:runner:1.0.1'
            androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

    }

Gradel 由 Android Studio 3.1 为新项目生成。

https://i.stack.imgur.com/k98p5.png

访问https://docs.gradle.org/current/userguide/dependency_management_for_java_projects.html

详情https://docs.gradle.org/current/userguide/declaring_dependencies.html


请注意,“testCompile”更改为“testImplementation”。
大多数答案以及最受欢迎的答案都集中在 com.google.gms:google-services 上,但这都是关于更新两个 gradle 文件中的旧命名样式
O
Om Infowave Developers

我已将 com.google.gms:google-services 从 3.2.0 更新到 3.2.1,警告停止出现。

 buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.1'
        classpath 'com.google.gms:google-services:3.2.1'

    }
}

你只需要改变版本,就像我有这个'com.google.gms:google-services:3.2.0'你需要做的只是用3.2.1替换3.2.0。
谢谢,我更新了错误的课程,这就是我收到错误的原因。
我的版本 classpath 'com.google.gms:google-services:4.1.0' 不是最新的,但是是的,它大于 3.2.0。还没解决!
@sud007 你能解释一下你面临什么问题或发布你的 build.gradle(项目级别)
H
Hovanes Mosoyan

使用当前最新版本的谷歌 gms 服务为我解决了这个问题。

在项目级别的 build.gradle 中:

buildscript {
    ...
    dependencies {
        classpath 'com.google.gms:google-services:3.2.1'
        ...  
    }
}

G
Gene

打开位于此处的 build.gradle 文件:

https://i.stack.imgur.com/Ktni5.png

这是编写依赖库的旧方法(对于 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.+'
}

这是为 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.+'
}

谢谢你,朋友!这似乎是截至 2019 年 1 月的最新答案
这个答案对第一次遇到这个问题的人很有帮助。虽然,OP 有一个不同的问题,即即使进行了这些更改,也会显示错误消息。
q
quangkid

谷歌回复:https://issuetracker.google.com/issues/74048134

仍有一些依赖项仍在使用编译,请仔细检查您的应用程序依赖项和传递依赖项。


我为我的项目删除了所有 build.gradles 中的所有依赖项,但仍然出现错误
编辑:它是由领域引起的,使用旧版本
E
Eric

https://issuetracker.google.com/issues/72479188 表示插件有时会引入“编译”依赖项,这就是触发警告的原因。可能只是最容易为该问题加注星标并等到他们修复它以指出哪些插件导致问题。


T
Tom

无需删除线。正如 Jkrevis 所写,将 com.google.gms:google-services 更新为 3.2.0 并停止警告。


您是否在项目的 build.gradle(Module:App) 中将每次出现的 'compile' 替换为 'implementation' 并将 build.gradle(Project) 中的 com.google.gms:google-services 更新为 3.2.0 ?
k
ken

就我而言,这是由 Realm 库引起的,在我将其更新到 Realm 的最新版本(目前为 5.1.0)后,问题解决了!

这是工作的gradle脚本:

buildscript {
repositories {
    jcenter()
    google()
}

dependencies {
    classpath 'com.android.tools.build:gradle:3.1.2'
    classpath "io.realm:realm-gradle-plugin:5.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.1'
  }
}

“io.realm:realm-gradle-plugin:1.1.0”给我造成了这个问题。我更新到最新版本,问题就消失了。
z
zhangliang

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

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


我认为这是一般的解决方案。问题可能是由您的任何一个或多个依赖项引起的
K
Khemraj Sharma

仅更新 google-service 版本对我不起作用。

首先确保您编译的所有依赖项都替换为实现。

更新项目中的所有依赖项。因为如果您的依赖项之一正在编译,那么您的项目将显示此错误。所以更新所有依赖版本。


H
Haileapp

我已尝试在 Android Studio 3.0.1 中将 google gms services 更改为最新的 com.google.gms:google-services:3.2.1,但警告仍然存在。

按照编译器的建议,我将所有 compile 依赖项更改为 implementation 并将 testCompile 更改为 testImplementation,如下所示。

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:mediarouter-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.google.firebase:firebase-ads:12.0.1'
implementation 'com.google.firebase:firebase-crash:12.0.1'
implementation 'com.google.firebase:firebase-core:12.0.1'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
implementation 'com.google.firebase:firebase-perf:12.0.1'
implementation 'com.google.firebase:firebase-appindexing:12.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

最后警告被删除!


R
RABI Hamza

转到项目级别的 build.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
}

P
PerrierCitror

在我的情况下,它是一个旧依赖项,它使用 compile 作为传递依赖项:com.jakewharton.hugo

从我的 gradle 中删除它后,它编译了。


t
tpn

对我来说,解决此问题的解决方法是使用旧版本的 Gradle,可以在 here 中找到:

我使用了 gradle-3.0-rc-1-src 版本,但其他版本也可以使用,尽管它可能不应该比 3.0 版本更新。

首先将 zip 文件解压缩到您喜欢的任何位置。

然后转到 File -> Settings -> Build, Execution, Deployment -> Gradle 并将设置更改为 Use local gradle distribution。之后确保 Gradle Home-field 指向您刚刚解压缩到的目录中的 .gradle 目录。

重建项目,一切都应该没问题。


F
Frank Eno

当前版本是 4.2.0:

构建脚本 {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.4.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    classpath 'com.google.gms:google-services:4.2.0'
}

}


M
Muhammad Muzamil

谷歌最近在 2021 年 9 月更新了它的服务。给了更新,我遇到了同样的问题,然后我更新了 android studio 中的 build.gradle 文件

旧版本有问题

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

更新了 build.gradle 中的代码

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

U
Unheilig

您可以执行以下两个选项:

在你的项目中添加类路径'com.google.gms:google-services:3.2.0':build.gradle 依赖项并替换你的模块:build.gradle 依赖于编译和实现,你不会收到任何警告消息。


O
Omae wa mou shindairu

只需从 build.gradlebuild script 添加

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

并且所有依赖项 "compile" 都替换为 "implementation"

这对我有用。


请注意,如果您使用 classpath,则必须在 buildscript 块内使用它;此外,不能在 buildscript 块内使用 implementation
J
Jagadesha NH

对我来说,将编译更改为实现已修复它

compile 'androidx.recyclerview:recyclerview:1.0.0'
compile 'androidx.cardview:cardview:1.0.0'
//Retrofit Dependencies
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'

implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
//Retrofit Dependencies
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'

D
Dr NVS

我尝试了这里提到的所有解决方案,但没有运气。我在我的 build.gradle 文件中发现如下:

dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
    }

我只是将其更改如下并保存并尝试构建成功。

dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
    }

T
Thiyagu

希望您受到 build.gradle(app) 的影响 如果这样做,请按照此步骤操作

用 build.gradle 中的 androidTestImplementation 替换 compile

androidTestImplementation 'com.android.support:appcompat-v7:27.1.1'
androidTestImplementation 'com.android.support:design:27.1.1'

很简单 !希望这能解决


U
Ujjwal Singh

就我而言,问题是 gradle 文件中带有以下行的 Google 服务 gradle 插件:

应用插件:'com.google.gms.google-services'

删除此问题解决了问题


A
Ayoub

去你build.gradle(应用程序级别)

build.gradle module app

并将“编译”一词替换为“实现”

它将工作 100%


这个答案没有用。 OP 已经声明这已经完成,所以它不可能有帮助。
我有同样的问题,我无法生成我的应用程序 apk bcoz,那个答案解决了我的问题
这不是同样的情况,OP已经说过他已经这样做了(我也在同一条船上)这是由于依赖关系
OP 说“我已经通过实现替换了每次出现的编译”。