ChatGPT解决这个技术问题 Extra ChatGPT

Could not find com.google.android.gms:play-services:3.1.59 3.2.25 4.0.30 4.1.32 4.2.40 4.2.42 4.3.23 4.4.52 5.0.77 5.0.89 5.2.08 6.1.11 6.1.71 6.5.87

referencing the play-services via gradle stopped working for me - boiled it down - even the sample I used as a reference in the first place stopped working: https://plus.google.com/+AndroidDevelopers/posts/4Yhpn6p9icf

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':auth'.
> Failed to notify project evaluation listener.
   > Could not resolve all dependencies for configuration ':auth:compile'.
      > Could not find com.google.android.gms:play-services:3.1.36.
        Required by:
            gpsdemos:auth:unspecified

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 3.577 secs

I fear that just the version increased but that raises 2 questions: #1) what is the new one? #2) why is the old version gone?

You can see the available versions of Play Services here: C:\Users\USERNAME\AppData\Local\Android\android-studio\sdk\extras\google\m2repository\com\google\android\gms\play-services
Install the Google Repository in the SDK manager.

C
CJBS

Check if you also installed the "Google Repository". If not, you also have to install the "Google Repository" in your SDK Manager.

Also be aware that there might be 2 SDK installations - one coming from AndroidStudio and one you might have installed. Better consolidate this to one installation - this is a common pitfall - that you have it installed in one installation but it fails when you build with the other installation.

https://i.stack.imgur.com/jPqsW.png


no - just mavenCentral() - be aware that you might have 2 sdk locations - one is shipped with AndroidStudio - that is a common pitfall
+1 but you mean: install "Google Repository" in your "Android SDK".
I hade to install both "Google Repository" and "Google Support Repository" to get it to work. +1
Thanks for the comment ligi. I didn't realize that Android studio started shipping an android sdk with it. Now I have 2 of them to manage :(.
Weird that this piece of info isnt clearly stated elsewhere. But thanks for the help =)
K
Khayam Gondal

Just install Google Repository form your sdk manager and than restart Android Studio.


T
Tommie C.

In addition to installing the repository and the SDK packages one should be aware that the version number changes periodically. A simple solution at this point is to replace the specific version number with a plus (+) symbol.

compile 'com.google.android.gms:play-services:+'

Google instructions indicate that one should be sure to upgrade the version numbers, however adding the plus deals with the changes in versioning. Also note that when building in Android Studio a message will appear in the status line when a new version is available.

One can view the available versions of play services by drilling down on the correct repository path:

https://i.stack.imgur.com/EnSib.png

References

This site also has instructions for Eclipse, and other IDE's.

https://i.stack.imgur.com/BjxQf.png


Changing my version to a '+' is what fixed it for me. Intellij was saying I should be using version 5.2.8, but the actual version that was available was 5.2.08
Problem with this answer is that the currently available version of the play services is 4.4.52, meaning a user can't even upgrade to 5+.
A
Amaro

I've been strugglin with this problem for hours till found this post. Just like @ligi said, some people have two SDK folders (Android Studio, which is bundled and Eclipse). The problem is that it doesn't matter if you downloaded the Google Play Services library on both SDK folders, your ANDROID_HOME enviroment variable must be pointing to the SDK folder used by the Android Studio.

SDK Folder A  (Used on Eclipse)
SDK Folder B  (Used on AS)

ANDROID_HOME=<path to SDK Folder B>

After change the path of this variable the error was gone.


S
Shudy

I had the same problem because I had:

compile 'com.google.android.gms:play-services:5.2.8'

and I solved changing the version numbers for a '+'. so the lines has to be:

compile 'com.google.android.gms:play-services:+'

This is a hack that could be detrimental in the future when you want a newer version of the library to be used but the compiler picks up an older version. You are basically telling gradle that you don't care which version of the Play services library your project uses.
The difficulty is that no matter where one digs, this environment does not lend itself to easily finding out what version is actually installed, all the Android docs are blatantly missing any clue of how to determine the version of "play" My SDK Manager tells me I simply have "26" (it's under "extras" not an API level), Some other window tells me it's 26.0.0. And I've tried these, and many other things version numbers... none of which work. So if you are concerned about people using this "hack", it is happening because they can't find the actual version number to use.
This simple trick solved this issue and I agree: documentation about what should be a simple choice if very frustrating and leads to errors. However this trick leads to another issue: MainActivity is not located and throws a ClassNotFound exception at build time
S
Shirkrin

Adding this as a second reference because I had a similar problem.. I had to explicitly add '.aar' as a registered file type under the 'Archives' category in AS settings.


B
BlackHatSamurai

If you already have Google Repository installed, make sure it's updated. I had to update my Google Repository and services. This was after I updated Android Studio.


u
user54636

I added a new environment variable ANDROID_HOME and pointed it to the SDK (C:\Program Files (x86)\Android\android-studio\sdk) that is inside the installation directory of Android Studio. (Environment variables are a part of windows; you access them through the advanced computer properties...google it for more info)


R
ReadyShow

I have the same question.

You should add some dependencies in build.gradle, just looks like this

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':libcocos2dx')
    compile 'com.google.firebase:firebase-ads:11.6.0'
// the key point line
    compile 'com.google.android.gms:play-services-auth:11.6.0'
}

4
4 revs, 2 users 82%

I too had the same problem and resolved.

As per the above-mentioned solutions by others, I tried all the things and it does not solve my problem.

Even if you have two SDK locations, no need to worry about it and check whether your android home is set to Android studio SDK (If you have the Android repository and everything in that SDK location).

Solution:

Go to Your project structure

Select your modules

Click the dependance tap on the right side

Add library dependency

"com.google.android.gms:play-service:+"

I hope it will solve your problem.


t
therealrootuser

By mistake I added the compile com.google.android.gms:play-services:5.+ in dependencies in build script block. You should add it in the second dependency block. make changes->synch project with gradle.


Y
Yairopro

Personally this post helped me to solve this issue by moving the google() to the top of the repositories.