android - 播放服务广告与 appcompat 冲突

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

当我添加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'
}

最佳答案

您正在使用

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

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

Dependencies using groupId com.android.support and androidx.* can not be combined

这意味着您正在使用支持库和 androidx 库。

你可以:

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

您可以查看 official release notes :

Warning: This release is a MAJOR version update and breaking change. The latest update to Google Play services and Firebase includes the following changes:

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

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

关于android - 播放服务广告与 appcompat 冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57777002/

相关文章:

java - 如何识别图像中选定的文本

firebase - 无法从Firebase读取List,始终在snapshot.data上返回null

javascript - 如何在 React Native 中更新配置文件(displayName)firebase?

android - 适用于 Android 的 Google Play 服务。如果禁用 wifi,位置客户端不会更新位置

android - 如何为我的 Google map 应用程序使用具有 Google Play 服务依赖性的非 Nexus 5 模拟器

android - Xamarin Google Play 服务组件回合制多人游戏示例

java - 在android的动态线性布局中添加事件OnClickListener

android - 新手 - 按钮的Android编码问题

android - 错误无法解决Android Studio 3.2.1中的recyclerview-v7

javascript - 如何将从 <input type ="datetime-local"> 收到的值转换为 firestore 格式?