Reputation: 2119
While using google map activity in my android application I get this error.
"Could not resolve com.google.android.gms:play-services:11.8.0."
Project level Gradle file:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Application level Gradle file:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.google.android.gms:play-services:11.8.0'
}
Upvotes: 0
Views: 4660
Reputation: 2119
So, finally I got the answer,
I've turned on gradle offline mode that's why it could not find out cached files for that version play-service.
I turned it off (under File-Settings-Build,Execution,Deployment-Gradle) and again sync project and some files have been downloaded then it works now.
Upvotes: 9
Reputation: 11245
You need to include this class path inside project level gradle.
classpath 'com.google.gms:google-services:3.0.0'
As well as inside app level build.gradle.
apply plugin: 'com.google.gms.google-services'
Upvotes: 2