22

Today, Android Studio stopped to sync properly due to configuration issues.

Could not resolve all files for configuration ‘:app:providerRepositoryDebugCompileClasspath’. Could not find firebase-analytics-impl.aar (com.google.firebase:firebase-analytics-impl:15.0.2). Searched in the following locations: https://jcenter.bintray.com/com/google/firebase/firebase-analytics-impl/15.0.2/firebase-analytics-impl-15.0.2.aar Could not find play-services-flags.aar (com.google.android.gms:play-services-flags:15.0.1). Searched in the following locations: https://jcenter.bintray.com/com/google/android/gms/play-services-flags/15.0.1/play-services-flags-15.0.1.aar

These two files exist, and I can download them through web browser.

I have fixed first issue by updating firebase core to 16.0.0. (Failed to resolve: firebase-analytics-impl), but I cannot fix the 2nd one.

What's wrong with Android Studio? Yesterday it worked well.

Please don't suggest to add flags library from gms. I tried that already.

vanste25
  • 1,754
  • 14
  • 39
  • Please explain why you gave me negative points. If you don't want, please skip this question. – vanste25 May 28 '18 at 09:41
  • set classpath `classpath 'com.google.gms:google-services:4.0.1'` – IntelliJ Amiya May 28 '18 at 09:56
  • 2
    I have the same issue with cordova. Suddenly it is not working anymore. – Robert May 28 '18 at 09:57
  • Got the same issue, too. In my case play-services-places-placereport and play-services-basement cannot be fetched. – MW. May 28 '18 at 10:01
  • To elaborate on my similar issues: We use cordova to create our app. Today I set up a clean workspace. Did cordova add android and build and there I get the same error. When I open the project with android studio, I see it there, too. Tried so far to play around with the library versions, but nothing helps. – Robert May 28 '18 at 10:18
  • 1
    @IntelliJAmiya Unfortunately, setting to 4.0.1 didn't work either. – Ivan Rigamonti May 28 '18 at 10:24
  • 1
    [Gustav](https://stackoverflow.com/users/2273583/gustav) would like to add: They should not down vote you - I am having the same issue. (copied from a now deleted answer (that wasn’t an answer)) – Ole V.V. May 28 '18 at 10:39
  • Same thing here, literally nothing helps, even clean reinstall of AS and all libraries – jujka May 28 '18 at 11:17
  • 2
    Please look at my answer for question https://stackoverflow.com/questions/50562212/gradle-build-tool-cannot-find-play-services-tasks-aar-why/50564970#50564970. – Ivan Rigamonti May 28 '18 at 11:19
  • @IvanRigamonti You are right, 2nd thing did the trick. Thanks! – vanste25 May 28 '18 at 11:21

3 Answers3

43

Fixed by changing order of repos in PROJECT build.grade:

Instead of

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

put

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

I think someone suggested this but I don't see his answer anymore.

Very strange issue.

vanste25
  • 1,754
  • 14
  • 39
  • It worked for me. Try to play around with repos, something weird happened there. – vanste25 May 28 '18 at 11:22
  • In my case everything is even worse: I have Failed to resolve: firebase-messaging Failed to resolve: support-core-ui Failed to resolve: fabric So essentially nothing really works, and I've tried everything: moving up and down repositories, updating play services and etc But thanks for the advice! – jujka May 28 '18 at 11:25
  • @GeorgySavatkov Did you update your dependencies to the latest versions? By doing that, I fixed Failed to resolve: firebase-analytics-impl issue. Also, did you update classpath to 4.0.1 ? – vanste25 May 28 '18 at 11:28
  • 3
    Oh, I just realised that `jcenter` has to be moved down in `allprojects` section. Your solution does work, thank you! It's still freaking ridiculous, I've spent like 4 hours figuring this out! – jujka May 28 '18 at 11:29
  • 1
    @GeorgySavatkov I am glad you fixed it. I spent too many time on this, too. – vanste25 May 28 '18 at 11:41
  • 2
    Thanks for the answer. Its really helps. +1 – Hardik Joshi Jul 02 '18 at 18:20
  • 2
    Yeah this works. @vanste25 You are right, someone suggested this but it not traceable now. Also, `google()` is required to be placed on top of all as suggested by @Denis in [this](https://stackoverflow.com/a/50564890/4632372) answer. – Mohammedsalim Shivani Sep 21 '18 at 07:31
10

They were changing and deleting old libraries, I guess.

I finally managed to get it working, by changing the order of repositories in project build.gradle:

    allprojects {
        repositories {
            google()
            maven {
                url "https://maven.google.com" // Google's Maven repository
            }
            jcenter()
        }
    }

jcenter should be the last.

  • 2
    try updating everything to last version, also update classpath to 4.0.1, as one other comment decribes, and check that jcenter is always the last – Denis Avguštin May 28 '18 at 11:17
  • Thank you. I tried various solutions, but this easy fix with changing a few lines helped me to finally solve the issue. I am using Ionic with Android version 6.4.0. – ossmalpha Jun 12 '18 at 17:31
2

Try below code

in project build.gradle

in dependencies tag

classpath 'com.google.gms:google-services:4.0.1'

and import repositories like below

allprojects {
    repositories {
        google()
        jcenter()
    }
}

in app build.gradle

repositories {
    google()
    jcenter()
}

Now the confusing part is why use google() not

maven { url "https://maven.google.com"  }

because google() is its replacement in android studio 3+

Also make sure to use correct version of firebase sdk from Firebase SDK documentation

Umar Ata
  • 4,170
  • 3
  • 23
  • 35