【问题标题】:play-services-ads conflicts with appcompat播放服务广告与 appcompat 冲突
【发布时间】:2020-07-17 09:33:49
【问题描述】:

当我将 implementation 'com.google.android.gms:play-services-ads:18.2.0' 添加到我的 build.gradle 时,Android Studio 会突出显示 implementation 'com.android.support:appcompat-v7:28.0.0' 并显示错误:

Dependencies using groupId com.android.support and androidx.* can not be combined but found IdeMavenCoordinates{myGroupId='com.android.support', myArtifactId='versionedparcelable', myVersion='28.0.0', myPacking='aar', myClassifier='null'} and IdeMavenCoordinates{myGroupId='androidx.interpolator', myArtifactId='interpolator', myVersion='1.0.0', myPacking='aar', myClassifier='null'} incompatible dependencies

我的 build.gradle 是:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    configurations.all {
        resolutionStrategy.force 'com.android.support:appcompat-v7:28.0.0'
    }
    defaultConfig {
        applicationId "com.XXXXXX.XXXXXX"
        minSdkVersion 14
        targetSdkVersion 28
        versionCode 3
        versionName "1.1.2"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.android.gms:play-services-ads:18.2.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

【问题讨论】:

  • 尝试使用实现 'com.google.android.gms:play-services-ads:16.0.0''
  • 用实现 'androidx.appcompat:appcompat:1.0.2' 替换实现 'com.android.support:appcompat-v7:28.0.0' 并告诉我它是否解决了您的问题。否则,我会尝试在我的电脑中实现并找到你的 gradle 中的错误。

标签: android firebase google-play-services android-appcompat androidx


【解决方案1】:

你正在使用

implementation 'com.google.android.gms:play-services-ads:18.2.0'

Google Play 服务在最新版本中迁移到了 AndroidX。

无法组合使用 groupId com.android.support 和 androidx.* 的依赖项

这意味着您同时使用了支持库和 androidx 库。

你可以:

  • 如下所述迁移到 androidx(在您的情况下,您必须将 appcompat 迁移到 implementation 'androidx.appcompat:appcompat:1.0.2'
  • 降级您的 google play 广告依赖项(但这不是真正的解决方案,因为您迟早必须迁移)

您可以查看official release notes

警告:此版本是主要版本更新和重大更改。 Google Play 服务和 Firebase 的最新更新包括以下更改:

从 Android 支持库迁移到 Jetpack (AndroidX) 库。除非您在应用中进行以下更改,否则库将无法运行:

  • com.android.tools.build:gradle 升级到v3.2.1 或更高版本。
  • compileSdkVersion 升级到 28 或更高版本。
  • 更新您的应用以使用 Jetpack (AndroidX);按照Migrating to AndroidX 中的说明进行操作。

【讨论】:

  • 要迁移到 AndroidX,请转到 Refactor -> Migrate to AndroidX。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-12-31
  • 2017-05-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多