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

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


当前回答

回到你的位置。在项目级别的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
}

其他回答

我有一个相同的警告导致com.google.gms:google-services。

解决方案是升级classpath com.google。Gms:google-services到类路径'com.google.gms:google-services:3.2.0'在文件中构建。gradle项目:

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版本中,依赖项compliword被替换为 实现

在android studio 3.1中依赖Warning

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中确定依赖

    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'

    }

graddel生成的Android Studio 3.1的新项目。

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

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

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

根据编译器的建议,我将所有编译依赖项更改为实现,并将testCompile更改为testimplemimplementation,如下所示。

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"
}

最后,警告被删除!

你有两种选择:

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

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

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

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

这对我很管用。

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