com.google.android.gms:play-services-measurement-base is being requested by various other libraries

210,541

Solution 1

The actual problem is discussed in the May, 23rd release note of https://developers.google.com/android/guides/releases#may_23_2018

Basically, you need to bump all Play Services and Firebase libraries to their latest version (which may be different for each since version 15). You may use https://mvnrepository.com/ to find the latest version for each library.

See also: https://firebase.google.com/support/release-notes/android#20180523

Solution 2

only working solution for me:

put it on the bottom of build.gradle

com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

Solution 3

Make Sure to keep Your Google play services dependencies and Firebase dependencies to latest version.

Also check all your gradle files, module level and project level, there has to be only one common version of dependency across all modules. Can be solved by keeping those versions in project level gradle variable.

Check here for Google play services update version

Google Play Services Latest

Check here for Firebase updated version

Firebase Latest

Check here for Firebase updated version for Android

Firebase Android Latest

Solution 4

I updated

implementation 'com.google.android.gms:play-services-analytics:16.0.3'

and it works for me

Solution 5

changing my build.gradle to the following worked for me:

ext {
  googlePlayServicesVersion   = "15.0.1"
}

allprojects {
  repositories {
      mavenLocal()
      maven { url 'http://maven.google.com' }
      jcenter { url "http://jcenter.bintray.com/" }
      google()
      maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url "$rootDir/../node_modules/react-native/android"
      }

      configurations.all {
        resolutionStrategy {
            force "com.google.android.gms:play-services-basement:$googlePlayServicesVersion"
            force "com.google.android.gms:play-services-tasks:$googlePlayServicesVersion"
        }
      }
  }
}
Share:
210,541

Related videos on Youtube

Ilja
Author by

Ilja

That dev at the local ☕️ shop sipping on late.

Updated on March 15, 2021

Comments

  • Ilja
    Ilja over 3 years

    I updated to gradle 4.0.1 and started receiving following error

    The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.4,15.0.4]], but resolves to 15.0.2. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

    My project doesn't use that dependency so I searched globally for it, and it it only comes up inside

    build/intermediates/lint-cache/maven.google/com/google/android/gms/group-index.xml

    as this line

    <play-services-measurement-base versions="15.0.0,15.0.2"/>
    

    So I tried deleting my build folder and cleaning the project, but it regenerates it with same values :/ hence error still remains

    • Priya Rajan
      Priya Rajan over 5 years
      Resolved here: Me too faced the same problem when trying to add crashlytics in firebase. Please update the latest version of dependencies for com.google.android.gms:play-services and com.google.firebase: ....... It will automatically resolved the issues
    • landrykapela
      landrykapela over 5 years
      I had the latest version and got this error so downgraded to 15.0.1 and it worked!
    • Patricio Sard
      Patricio Sard over 5 years
      Please go to this issue and star it. It seems there are a lot of problems because there were a lot of libraries unpublished from jCenter.
  • PaulR
    PaulR about 6 years
    maven.google.com is also suitable for looking up the released versions of these libraries.
  • ARLabs
    ARLabs about 6 years
    For me this solution hide the message, that is then raised in another way: "Android dependency 'com.google.android.gms:play-services-measurement-base' has different version for the compile (15.0.4) and runtime (16.0.0) classpath. You should manually set the same version via DependencyResolution"
  • jasonhudgins
    jasonhudgins about 6 years
    This isn't working, it's just spits out the same error with no dependency graph.
  • Dibzmania
    Dibzmania almost 6 years
    LifeSaver. Google should streamline this versioning. It's a pain
  • Jacob Joel
    Jacob Joel almost 6 years
    Your answer helped me figure this out. But I had to use this post to actually get the correct versions included in my project and get past the errors.
  • Kata Lune
    Kata Lune almost 6 years
    you need to remove apply plugin: 'com.google.gms.google-services' line before trying this to avoid showing error
  • miszmaniac
    miszmaniac almost 6 years
    I disabled the plugin, and checked dependencies. But there wasn't any library that had dependency to 15.0.4 as stated in exception The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.4,15.0.4], [16.0.0,16.0.0]], but resolves to 16.0.0.
  • NoHarmDan
    NoHarmDan almost 6 years
    @miszmaniac I had the exact same issue. Downgrading both play-services-analytics and firebase-core to 16.0.0 solved the issue.
  • miszmaniac
    miszmaniac almost 6 years
    This new system of non equal versions for Firebase library is tragedy for now. Yesterday we had a random crash at app start, because firebase was not able to init() for some odd reason... we had to disable (in manifest) firebase-perf to be able to remove crash
  • Eric Kim
    Eric Kim almost 6 years
    now I am getting different error The library com.google.firebase:firebase-analytics is being requested by various other libraries at [[16.0.3,16.0.3]], but resolves to 16.0.1. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
  • Student
    Student almost 6 years
    I used the latest version of all libraries but the error remains.
  • Nguyễn Anh Tuấn
    Nguyễn Anh Tuấn almost 6 years
    Thank you. I did the same thing, it's work very well.
  • Neri
    Neri over 5 years
    Its the only solution that worked for me. Even with all gradle libraries up to date.
  • mmmatey
    mmmatey over 5 years
    Don't ever do that. It's very bad answer, it can lead to multiple crashes and changes which you will never now.. because this will always request new version of library.
  • pmont
    pmont over 5 years
    It works, but use it as a last resort. I sync'd all the Google Play and Firebase versions, but one library refused to accept that version (it was hardcoded to require one and only one specific version).
  • Dane Lowrey
    Dane Lowrey over 5 years
    I had the same issue and used the mvnreposityory.com to find the latest google versions of the libraries in both of my gradle.build files and my issues were resolved.
  • Lassi Kinnunen
    Lassi Kinnunen over 5 years
    just saying that using the latest version should not be a problem. But it will probably be. this whole problem comes from trying to use latest versions.
  • Danish
    Danish over 5 years
    thank you, it was helpful for me and solved my error. atleast gave me direction for next errors which i put them in same resolutionStrategy
  • Kimi Chiu
    Kimi Chiu over 5 years
    Here's a joke, Firebase Android SDKs now have independent version numbers, allowing for more frequent, flexible updates..
  • Aaron
    Aaron over 5 years
    To clarify, it's adding the ext {...} block to force the version that fixes the issue
  • user3369427
    user3369427 over 5 years
    If you update all the libraries to their latest respective versions you get a warning that says "All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes)." Is this expected? How do you resolve this as well as the original problem?
  • user2529011
    user2529011 over 5 years
    @htw thats a nope for me.
  • gauravsngarg
    gauravsngarg over 5 years
    Worked for me after searching lot of articles. Error was coming while adding firebase database. Thank you
  • Martin Zeitler
    Martin Zeitler over 5 years
    this is the worst one can do; ignoring the problem is not a "solution".
  • Gesh
    Gesh over 5 years
    This should be the accepted answer. Google just replaced their internal pain of releasing and testing many libs at the same version, with the pain of every other Android engineer having to deal with their inconsistencies!
  • Devansh Maurya
    Devansh Maurya over 5 years
    Can I thank you more? The solution helped me to save hours of work :)
  • publicknowledge
    publicknowledge over 5 years
    this was useful. Using react-native and had to update the packages we were using to latest in these links.
  • NateS
    NateS over 5 years
    It can happen even if you depend on only a single Google lib! See my answer for why (very old Android Gradle plugin).
  • Kapil Soni
    Kapil Soni about 5 years
    @Gowthaman M : sir i got error after put above in the build.gradle--- error: cannot find symbol public class FirebasePluginInstanceIDService extends FirebaseInstanceIdService {
  • hitautodestruct
    hitautodestruct about 5 years
    not working for me, it just gives me a different error
  • leeCoder
    leeCoder over 4 years
    this is where the magic lies. All dependencies in the app/build.gradle and then the topmost build.gradle file update all dependencies
  • Anand_5050
    Anand_5050 over 4 years
    where i need to put this line ?
  • SriTeja Chilakamarri
    SriTeja Chilakamarri over 4 years
    Thank you, using these versions got my problem solved.
  • Prajna
    Prajna almost 4 years
    in android/app/build.gradle @Anand_5050
  • Cícero Moura
    Cícero Moura over 2 years
    The best way to found out the solution ever!