I'm trying to add google play services to my libGDX project in IntelliJ Idea. I've followed the setup guide here: https://developers.google.com/android/guides/setup
which looks pretty straightforward. I just added those lines to my build.gradle in the corresponding section, so things look now like:
project(":android") {
apply plugin: "android"
apply plugin: 'com.android.application'
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
compile 'com.google.android.gms:play-services:11.2.0'
}
}
Then I try to sync my gradle project in Idea just to get that "Failed to resolve" error.
Well, the setup guide also says "Be sure you update this version number each time Google Play services is updated", but the problem is that it seems nearly impossible to find that version number: my Google Play Services SDK version according to the Android SDK manager is "43", and so far I have been unable to correlate such "11.2.0" or whatever typical version string with the "43" version number. Not that the setup guide says nothing about that.
Anyway, I have tried a lot of things from the plethora of questions related to this to no avail. Specifically, I have to point out that I do have my Android SDK properly updated and I'm sure it is the one it's being used by Idea (I've already triple-checked this...):
I'm using the API level 26, but anyway the other defines do use the very same directory for the Android SDK. Moreover, I do NOT have any other android SDK installed at all in this laptop, so there's no question about Idea being using that one and that one only.
Any ideas are more than welcome.
Thanks in advance!
This question is related to
java
android
intellij-idea
gradle
libgdx
In my case I was using version 17.0.1 .It was showing error.
implementation "com.google.android.gms:play-services-location:17.0.1"
After changing version to 17.0.0, it worked
implementation "com.google.android.gms:play-services-location:17.0.0"
Reason might be I was using maps dependency of version 17.0.0 & location version as 17.0.1.It might have thrown error.So,try to maintain consistency in version numbers.
I had the same problem and it resolved by disabling Gradle's offline mode although I could not remember when I did disable it!
Here's the solution:
How to disable Gradle 'offline mode' in android studio? [duplicate]
I tried solving this problem for hours after I haven't used Android Studio some time and wasn't aware of the updates.
It is important that google()
is the first item that stands in repositories
like this:
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
Somehow google()
was the second item after jcenter()
, so everything was messed up and didn't work. Maybe this helps someone.
I had the issue when I put jcenter()
before google()
in project level build.gradle. When I changed the order and put google()
before jcenter()
in build.gradle the problem disappeared
Here is my final build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
this is probably about you don't entered correct dependency version. you can select correct dependency from this:
file>menu>project structure>app>dependencies>+>Library Dependency>select any thing you need > OK
if cannot find your needs you should update your sdk from below way:
tools>android>sdk manager>sdk update>select any thing you need>ok
Check you gradle settings, it may be set to Offline Work
I had that problem. And I found this solve. In Android Studio, Open File menu, and go to Project Structure, In Module app, go to dependencies tab and you can add 'com.google.android.gms:play-services:x.x.x' by clicking on + button.
A more up to date answer:
allprojects {
repositories {
google() // add this
}
}
And don't forget to update gradle to 4.1+ (in gradle-wrapper.properties):
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
source: https://developer.android.com/studio/build/dependencies.html#google-maven
At the latest Google Play Services 15.0.0
, it occurs this error when you include entire play service like this
implementation 'com.google.android.gms:play-services:15.0.0'
Instead, you must specific the detail service like Google Drive
com.google.android.gms:play-services-drive:15.0.0
I got this error too but for a different reason. It turns out I had made a typo when I tried to specify the version number as a variable:
dependencies {
// ...
implementation "com.google.android.gms:play-services-location:{$playServices}"
// ...
}
I had defined the variable playServices in gradle.properties in my project's root directory:
playServices=15.0.1
The typo was {$playServices}
which should have said ${playServices}
like this:
dependencies {
// ...
implementation "com.google.android.gms:play-services-location:${playServices}"
// ...
}
That fixed the problem for me.
Google Play services SDK is inside Google Repository
.
Start Intellij IDEA.
On the Tools menu, click Android > SDK Manager.
Update the Android SDK Manager: click SDK Tools, expand Support Repository, select Google Repository, and then click OK.
Current Google Repository version is 57.
After update sync your project.
EDIT
From version 11.2.0
, we've to use the google maven repo so add google maven repo link in repositories tag. Check release note from here.
allprojects {
..
repositories {
...
maven {
url 'https://maven.google.com'
// Alternative URL is 'https://dl.google.com/dl/android/maven2/'
}
}
}
I have found following solution to replace following code
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
It's work fine for me
Add this to your project-level build.gradle
file:
repositories {
maven {
url "https://maven.google.com"
}
}
It worked for me
Source: Stackoverflow.com