3

When I add implementation 'com.google.android.gms:play-services-ads:18.2.0' to my build.gradle, Android Studio highlights implementation 'com.android.support:appcompat-v7:28.0.0' with the error:

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

My build.gradle is:

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'
}

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
Kit
  • 89
  • 1
  • 6
  • try using implementation 'com.google.android.gms:play-services-ads:16.0.0'' – Dany Minassian Sep 02 '19 at 16:19
  • replace implementation 'com.android.support:appcompat-v7:28.0.0' with implementation 'androidx.appcompat:appcompat:1.0.2' and let me know if it fixes your problem. Otherwise, I'll try to implement and find the bug in your gradle in my pc. – Fahim Al Mahmud Ashik Sep 02 '19 at 16:21

1 Answers1

7

You are using

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

Google Play services migrated to AndroidX in the latest release.

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

It means that you are using both, support libraries and androidx libraries.

You can:

  • migrate to androidx as described below (in your case you have to migrate appcompat to implementation 'androidx.appcompat:appcompat:1.0.2')
  • downgrade your google play ads dependencies (but it is not a real solution because you have to migrate sooner or later)

You can check the 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:

Migration from Android Support Libraries to Jetpack (AndroidX) Libraries. Libraries will not work unless you make the following changes in your app:

  • Upgrade com.android.tools.build:gradle to v3.2.1 or later.
  • Upgrade compileSdkVersion to 28 or later.
  • Update your app to use Jetpack (AndroidX); follow the instructions in Migrating to AndroidX.
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841