74

I'm getting multiple "Failed to Resolve" issues when syncing my project. They are all firebase and play-services related. I made sure they are all the same (11.2.0). I've also checked and the latest version for both is 11.2.0. Also, all the other answers to similar questions involve updating Google play services and repository in the SDK Manager but mine is already up to date.

enter image description here

enter image description here

Any idea why I can't sync my project?

EDIT - Current working solution

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:3.0.0'
        classpath 'com.google.firebase:firebase-plugins:1.0.4'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://maven.google.com" } 
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
rigotre
  • 942
  • 2
  • 7
  • 14

6 Answers6

137

Add maven { url "https://maven.google.com" } to your root level build.gradle file

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}
Wilik
  • 7,630
  • 3
  • 29
  • 35
  • 1
    Details in the [AS documentation](https://developer.android.com/studio/build/dependencies.html#google-maven) – Bob Snyder Aug 15 '17 at 16:53
  • 1
    @BobSnyder Just tried this. Added the maven repo and then changed my dependencies back to 11.2.0 and I got the same issues. – rigotre Aug 15 '17 at 16:58
  • It worked but you need to apply in project level build gradle file – Hanuman Sep 20 '17 at 05:41
  • 2
    Make sure `maven {...}` is added under `allprojects/repositories`, that got me – Oblivionkey3 Nov 23 '17 at 06:00
  • While this solves to the problem I was having, I'm curious as to why it just came out of know where. I was using firebase fine in my project. Then I think the only thing I did was deleted a 3rd party library then syncing failed with this error – Stylishcoder Jan 10 '19 at 11:13
34

Play services and Firebase dependencies are now available via maven.google.com with the release of version 11.2.0 of Google Play services and Firebase.

You can find the Google Play Services official doc here and the firebase doc here..

allprojects {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
    }
}

If you are using the android gradle plugin 3.x you can also use:

allprojects {
    repositories {
        jcenter()
        google()
    }
}
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • 2
    Just tried this with no luck. I checked my gradle version and it is 2.3.3. I also attempted simply adding `{url 'maven.google.com' }` which didn't work either. – rigotre Aug 15 '17 at 17:28
  • `google()` doesn't work for me or the OP--see comments on question. We are both using `com.android.tools.build:gradle:2.3.3`. Any idea what's wrong? – Bob Snyder Aug 15 '17 at 17:47
  • 1
    Update - turns out I was putting the `google()` repository in the wrong section. However, I had to use `maven { url "https://maven.google.com" }` because `google()` isn't working for me or Bob. – rigotre Aug 15 '17 at 17:54
  • 1
    @BobSnyder I've just updated the answer. google() repo seems work only with android gradle plugin 3.x – Gabriele Mariotti Aug 15 '17 at 21:14
  • For anyone interesting in using version 3.0.0 of the Android Plugin for Gradle, [here are the migration instructions](https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html). – Bob Snyder Aug 15 '17 at 21:42
  • Thanks, you saved my days. For Quickblox user while running their sample project from git , We need to add google() in project level graddle as it`s version is 3.x . – Kumar Raj Nov 22 '18 at 05:47
12

I just fixed same error by adding firebase-core dependency.

implementation 'com.google.firebase:firebase-core:16.0.1'
Zeero0
  • 2,602
  • 1
  • 21
  • 36
2

With the 16.0.0 release of firebase I had to

  • set most my google play services libraries to 15.0.0 analytics and tagmanager needed to be 16.0.0
  • set my support library versions to 27.1.1
  • firebase-core to 16.0.0

Built against sdk 27

Extra Changes:

I also had to update my analytics to 16.0.0

  • implementation "com.google.android.gms:play-services-analytics:16.0.0"

Part of the independent versions thing Android did recently I am guessing. May need to try going up or down a version on the google play services and firebase libraries

Jim Factor
  • 1,465
  • 1
  • 15
  • 24
1

The best Method to fix this problem is not using the manual method of linking firebase to your app.

I have tried adding latest firebase repo by referring to this Link .

It showed error " failed to resolve the dependencies firebase 11.2.0"

FireBase recommends adding firebase to your app with the help of FireBase Assistant for Android Studio Version 2.2 and Higher. Manually adding the latest library to build-gradle(module) result in an error as above.

Firebase assistant added lower versions 10.0.1 automatically to dependencies on the module gradle-build which is compatible and could be resolved.

Using Firebase assistant is so easy and 2 step process. For reference, You can use the "Use the Firebase Assistant" section on the same link mentioned above.

It Really worked Out with my Android Studio 2.3.3. And also make sure Your Google Repository is up to date

0

From tools-> sdk manager-> sdk tools install google play service and google repository and sync your project will work fine