【问题标题】:Why do I get "Configuration 'compile' is obsolete"为什么我会收到“配置‘编译’已过时”
【发布时间】:2018-10-28 15:05:14
【问题描述】:

我已阅读有关此问题的 SO 主题并添加了

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

构建.gradle,但它没有帮助。这是完整的gradle:

buildscript {
    repositories {
        maven {
            url 'https://maven.fabric.io/public'
        }
        mavenCentral()
        jcenter()
        google()
    }
    dependencies {
        classpath 'io.fabric.tools:gradle:1.26.1'
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:3.2.1'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url "https://jitpack.io" }
    maven { url 'https://maven.fabric.io/public' }
    maven {
        url uri('mint-plugin-repo-5.2.4')
    }
    google()
}
android {

    flavorDimensions "default"

    signingConfigs {
        config {
            keyAlias 'xxx'
            keyPassword 'xxx'
            storeFile file('/Users/claude/Documents/xxx')
            storePassword 'xxx'
        }
    }
    compileSdkVersion 28

    defaultConfig {
        targetSdkVersion 28
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
        minSdkVersion 19
    }

    productFlavors {
        So_TEST {

            applicationId "com.bluelionsolutions.mytaxicontrol"
            versionName "5.0.3.4"

            buildConfigField 'String', 'mtc', '"xxx"'
            resValue "string", "app_name", "xxx"

            resValue "string", "google_maps_api_key", "xxx"
        }
    }
}

dependencies {
    implementation 'com.braintreepayments.api:drop-in:3.7.0'
    implementation 'commons-codec:commons-codec:1.10'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:mediarouter-v7:28.0.0'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.google.android.gms:play-services:11.8.0'
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.5@aar') {
        transitive = true;
    }
}
apply plugin: 'com.google.gms.google-services'

【问题讨论】:

  • 您的项目是否包含任何其他模块?我在您的代码中没有看到 api fileTree(include: ['*.jar'], dir: 'libs') 行。也许你忘了包括它?
  • 已添加。没有帮助。
  • 您是否尝试通过 Gradle -> :app -> build -> clean 清理项目?
  • 出于好奇,问题是哪个插件或哪个依赖项?

标签: android android-studio android-gradle-plugin build.gradle


【解决方案1】:

Google 服务 Gradle 插件已过时。请改用 4.x 版本:

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

但要真正找到罪魁祸首,请在模块上使用dependencies 任务并找到compile 配置:

gradle :app:dependencies

此外,您可以考虑重新排序您的 repositories 定义。

【讨论】:

    【解决方案2】:

    自 Android Gradle 插件 3.0.0 起,编译已弃用。

    根据您的用例使用实现或 api。

    实现和api的区别link

    【讨论】:

      猜你喜欢
      • 2018-11-30
      • 2012-03-13
      • 2019-12-06
      • 2018-07-20
      • 1970-01-01
      • 2021-07-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多