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

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


当前回答

希望build.gradle(app)对你有影响 如果是这样,请执行此步骤

在build.gradle中将compile替换为androidtestimplemimplementation

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

如此简单!希望这能解决

其他回答

我有一个相同的警告导致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

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

在项目级别build.gradle:

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

去你的建筑。Gradle(应用级)

构建。Gradle模块app

将“编译”替换为“实现”

100%可以正常工作

打开构建。Gradle文件位于这里:

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

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