【问题标题】:Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'. How to fix?配置“编译”已过时,已替换为“实现”和“API”。怎么修?
【发布时间】:2019-08-19 18:01:56
【问题描述】:

在同步当前项目时,我收到如下警告:“错误配置‘编译’已过时,已替换为‘实现和‘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

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

警告:配置“编译”已过时,已替换为“实施”和“API”。 它将在 2018 年底删除。有关更多信息,请参阅:http://d.android.com/r/tools/update-dependency-configurations.html 受影响的模块:app

【问题讨论】:

  • 您在 2.2.0 版本中引入了 Realm 的 gradle 插件,它将 Realm 依赖项添加为 compile。您可能想要升级 Realm,或者按照文档中的说明手动添加依赖项。

标签: android android-gradle-plugin


【解决方案1】:

该警告可能是由您导入应用程序的其他库引起的。
在他们的 gradle 中,他们使用已弃用的 compile 字词导入其他库。

将您的库更新到最新版本
我建议在每次更改 build.gradle 后同步 gradle 文件并构建项目,以防您的 android 库或编译的 sdk 版本等无法使用。

【讨论】:

  • @Vibhu 当你说'我试图将'编译'更改为'实现'';你在 app/build.gradle 中做了什么改变,因为我看到他们都在使用“实现”
【解决方案2】:

尝试更新

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

Android Studio 会自动推荐最新版本。

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

【讨论】:

    猜你喜欢
    • 2018-11-24
    • 1970-01-01
    • 2019-11-03
    • 1970-01-01
    • 2019-12-06
    • 1970-01-01
    • 2018-07-20
    • 1970-01-01
    • 2018-07-15
    相关资源
    最近更新 更多