karatuno
karatuno

Reputation: 395

Updating google play services in old project

I have this old project which uses play-services-location:9.0.1 now I want it to update to play-services-location:11.8.0. So, i changed it in app build.gradle file and try sync but shows error
I'm new to android studio any help would be appreciated.

older build.gradle(Module:app)

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion '26.0.2'

defaultConfig {
    applicationId "com.tinmegali.mylocation"
    minSdkVersion 19
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'

compile 'com.google.android.gms:play-services-location:9.0.1'
}

new build.gradle(Module:app)

apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '26.0.2'

defaultConfig {
    applicationId "com.tinmegali.mylocation"
    minSdkVersion 19
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:27.0.2'

compile 'com.google.android.gms:play-services-location:11.8.0'
}

Upvotes: 1

Views: 365

Answers (2)

Jorgesys
Jorgesys

Reputation: 126465

We can add automatically the google maven repository by clicking 'add google maven repository and sync project'.

But sometimes it doesn´t work so we need to add manually the google maven repository:

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

Example:

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

Upvotes: 0

Jeff G
Jeff G

Reputation: 122

Try clicking 'add google maven repository and sync project' on the error message.

This should add google maven to your build.gradle file and fix the problem

Upvotes: 2

Related Questions