How to compile play-services:11.2.0

24,087

Instead of variable version name

compile 'com.android.support:appcompat-v7:26.+'

Use constant version, latest is 26.1.0

compile 'com.android.support:appcompat-v7:26.1.0'

You've google maven repo link in buildscript repository list, You should also add google maven repo in project dependencies repository list of your root build.gradle file

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

Selective compile is better option instead of complete play-services artifacts, you should choose what you needed in your project.

compile 'com.google.android.gms:play-services:11.2.0'  // -> latest is 11.4.0

break it into your required artifact, like

compile 'com.google.android.gms:play-services-maps:11.4.0'
compile 'com.google.android.gms:play-services-places:11.4.0'
compile 'com.google.android.gms:play-services-location:11.4.0'

If you're using Android Plugin for Gradle 3.0.0 or latter version

repositories {
      mavenLocal()
      mavenCentral()
      google()        //---> Add this
} 

replace compile with implementation, More about this replacement here

Share:
24,087

Related videos on Youtube

Nguyễn Đạt
Author by

Nguyễn Đạt

Updated on July 12, 2020

Comments

  • Nguyễn Đạt
    Nguyễn Đạt almost 4 years

    I want to get current place of my device, and I follow this link:google And this tutorial requires Google Play services version 11.2.0 or later. But when I compile 'com.google.android.gms:play-services:11.2.0', I get :

    Error:(26, 13) Failed to resolve: com.android.support:appcompat-v7:26.0.0
    

    here is my build.gradle(Module:app):

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 26
        buildToolsVersion "26.0.1"
        defaultConfig {
            applicationId "com.example.administrator.googlemap"
            minSdkVersion 15
            targetSdkVersion 26
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        compile 'com.android.support:appcompat-v7:26.+'
        compile 'com.google.android.gms:play-services:11.2.0'
        compile 'com.google.android.gms:play-services-maps:11.0.2'
        compile 'com.google.android.gms:play-services-places:11.0.2'
        compile 'com.google.android.gms:play-services-location:11.0.2'
        testCompile 'junit:junit:4.12'
    }
    

    And here is my build.grandle(Project)

    buildscript {
        repositories {
            jcenter()
            maven { url "https://maven.google.com/"}
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:2.3.3'
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            jcenter()
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    

    How can I resolve this Error.?