配置“编译”已过时,已被“实现”和“ api”替换。怎么修?

时间:2019-03-28 20:41:49

标签: android android-gradle

在同步当前项目时,我收到警告,例如:“错误配置'compile'已过时,已被'implementation和'api'代替。如何解决此错误。

build.gradle(项目:xyz)

buildscript {
repositories {
    jcenter()
    google()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.3.1'
    classpath "io.realm:realm-gradle-plugin:2.2.0"
    classpath 'com.google.gms:google-services:4.0.1'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

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

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

bulid.gradle(module:app)

apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'com.google.gms.google-services'


android {
    compileSdkVersion 28

    defaultConfig {
        applicationId "com.app.wordpress"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        vectorDrawables.useSupportLibrary = true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"


    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    testImplementation 'junit:junit:4.12'

    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'

    implementation 'com.google.android.gms:play-services-analytics:16.0.8'
    implementation 'com.google.firebase:firebase-messaging:17.4.0'
    implementation 'com.google.firebase:firebase-config:16.4.0'
    implementation 'com.google.firebase:firebase-invites:16.1.1'

    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation('com.squareup.retrofit2:retrofit:2.0.0-beta4') {
        exclude module: 'okhttp'
    }
    implementation 'com.squareup.okhttp3:okhttp:3.2.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.0.1'
    implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'


    implementation 'com.balysv:material-ripple:1.0.2'

}

WARNING

我试图将“编译”更改为“实现”。

警告:配置'compile'已过时,并已由'implementation'和'api'代替。 它将于2018年底删除。有关更多信息,请参阅:http://d.android.com/r/tools/update-dependency-configurations.html 受影响的模块:应用

2 个答案:

答案 0 :(得分:0)

警告可能是由导入到应用程序中的其他库引起的。
在此过程中,他们使用了已弃用的compile单词导入了其他库。

将您的库更新为最新版本
我建议在每次对build.gradle进行更改后,同步gradle文件并构建项目,以防某些不适用于您的android库或编译的sdk版本等。

答案 1 :(得分:0)

尝试更新

com.google.gms:google-services from 4.0.1 to 4.2.0(当前最新版本)。

最新版本将由Android Studio自动建议。

同样,请尝试升级已包含的软件包。