Robin
Robin

Reputation: 10368

Android studio play-services-ads:12.0.1 conflicts with appcompat-v7:27.1.0

I am building an application with google ADS sdk and it was working fine until today I got notified to update Android studio, along with it I have also prompt to update Gradle to 4.4 and all the support library version to 27.1.0.

implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.google.android.gms:play-services-ads:12.0.1'

Then I got the Gradle error saying that Android dependency 'com.android.support:support-v4' has different version for the compile (26.1.0) and runtime (27.1.0) classpath. You should manually set the same version via DependencyResolution

I searched my code and there is not a single word that can match "26.1.0". I also tried to delete all the build/gradle cache but still cannot get rid of this problem. So I use gradlew.bat -q dependencies to find that it seems ADS library has the wrong dependency.

these two lines is very suspicious:

+--- com.android.support:support-v4:26.1.0
+--- com.android.support:support-media-compat:26.1.0

Comparing to other dependency settings

+--- project :MyAdsProject
+--- com.android.support:appcompat-v7:27.1.0
|    +--- com.android.support:support-annotations:27.1.0
|    +--- com.android.support:support-core-utils:27.1.0
|    |    +--- com.android.support:support-annotations:27.1.0
|    |    \--- com.android.support:support-compat:27.1.0
|    |         +--- com.android.support:support-annotations:27.1.0
|    |         \--- android.arch.lifecycle:runtime:1.1.0
|    |              +--- android.arch.lifecycle:common:1.1.0
|    |              \--- android.arch.core:common:1.1.0
|    +--- com.android.support:support-fragment:27.1.0
|    |    +--- com.android.support:support-compat:27.1.0 (*)
|    |    +--- com.android.support:support-core-ui:27.1.0
|    |    |    +--- com.android.support:support-annotations:27.1.0
|    |    |    +--- com.android.support:support-compat:27.1.0 (*)
|    |    |    \--- com.android.support:support-core-utils:27.1.0 (*)
|    |    +--- com.android.support:support-core-utils:27.1.0 (*)
|    |    +--- com.android.support:support-annotations:27.1.0
|    |    +--- android.arch.lifecycle:livedata-core:1.1.0
|    |    |    +--- android.arch.lifecycle:common:1.1.0
|    |    |    +--- android.arch.core:common:1.1.0
|    |    |    \--- android.arch.core:runtime:1.1.0
|    |    |         \--- android.arch.core:common:1.1.0
|    |    \--- android.arch.lifecycle:viewmodel:1.1.0
|    +--- com.android.support:support-vector-drawable:27.1.0
|    |    +--- com.android.support:support-annotations:27.1.0
|    |    \--- com.android.support:support-compat:27.1.0 (*)
|    \--- com.android.support:animated-vector-drawable:27.1.0
|         +--- com.android.support:support-vector-drawable:27.1.0 (*)
|         \--- com.android.support:support-core-ui:27.1.0 (*)
\--- com.google.android.gms:play-services-ads:12.0.1
     +--- com.google.android.gms:play-services-ads-lite:12.0.1
     |    +--- com.google.android.gms:play-services-basement:12.0.1
     |    |    +--- com.android.support:support-v4:26.1.0
     |    |    |    +--- com.android.support:support-compat:26.1.0 -> 27.1.0 (*)
     |    |    |    +--- com.android.support:support-media-compat:26.1.0
     |    |    |    |    +--- com.android.support:support-annotations:26.1.0 -> 27.1.0
     |    |    |    |    \--- com.android.support:support-compat:26.1.0 -> 27.1.0 (*)
     |    |    |    +--- com.android.support:support-core-utils:26.1.0 -> 27.1.0 (*)
     |    |    |    +--- com.android.support:support-core-ui:26.1.0 -> 27.1.0 (*)
     |    |    |    \--- com.android.support:support-fragment:26.1.0 -> 27.1.0 (*)
     |    |    \--- com.google.android.gms:play-services-basement-license:12.0.1
     |    \--- com.google.android.gms:play-services-ads-lite-license:12.0.1
     +--- com.google.android.gms:play-services-basement:12.0.1 (*)
     +--- com.google.android.gms:play-services-gass:12.0.1
     |    +--- com.google.android.gms:play-services-basement:12.0.1 (*)
     |    \--- com.google.android.gms:play-services-gass-license:12.0.1
     \--- com.google.android.gms:play-services-ads-license:12.0.1

Does any one how to get rid of this? ADS 12.0.1 is already newest release currently.

Upvotes: 4

Views: 4324

Answers (2)

Rifat
Rifat

Reputation: 157

I can fix this problem with add this on my depedencies

implementation 'com.android.support:support-v4:28.0.0'

OR

add this code on your app gradle

android {
    configurations.all {
        resolutionStrategy.force 'com.android.support:support-v4:28.0.0'
    }
}

Upvotes: 0

Sneh Pandya
Sneh Pandya

Reputation: 8493

In your app level build.gradle:

android {
    configurations.all {
        resolutionStrategy.force 'com.android.support:support-v4:27.1.1'
    }
}

This will tell your gradle configuration to forcefully pick and apply support-v4:27.1.1 everywhere it's imported!

Hope this helps!

Upvotes: 5

Related Questions