0

I'm trying to add a banner add to a new app of mine and I've hit a roadblock adding the Gradle dependencies. I've been following the Admob tutorial on how to do it Admob Get Started Link

What I'm trying to use is the following

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1' 
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android.gms:play-services-ads:17.0.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'}

However the line with "appcompat-v7:27.1.1" gets underlined with the following message:

All com.android.support libraries must use the exact same version specification, Found version 27.1.1, 26.1.0. Examples include com.android.support:animated-vector-drawable:27.1.1 andcom.android.supports:customtabs:26.1.0

This underline warning only shows up when I add in the dependency for admob, specifically:

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

How/what should I be doing to fix this? I was testing this out earlier in the week and I didn't have any errors, the only thing I've added since then is permissions for phone vibration which I can't imagine has any effect. My app crashes on the opening screen

Diesel
  • 519
  • 1
  • 6
  • 24

2 Answers2

0

Have you tried adding the library with the old version, but with new version??
com.android.support:customtabs:26.1.0 is your error so you need to add this:

implementation "com.android.support:customtabs:27.1.1"  

It's an confusing error because you are not directly using this library, but more of the libraries you use, depend on this one, so you have to explicitly set which version to use

Martin Lund
  • 1,159
  • 9
  • 17
0

The issue is happening because there are two different versions of support libraries sync one by ads and another by app compat To solve the issue use

    configurations.all 
{ resolutionStrategy.force 'com.android.supports:customtabs:27.1.1'
    resolutionStrategy.force 'com.android.support:animated-vector-drawable:27.1.1'
     }
    dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']
        ........
Wasim
  • 386
  • 1
  • 4
  • 12