简体   繁体   English

在旧项目中更新Google Play服务

[英]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 . 我有一个使用play-services-location:9.0.1旧项目,现在我希望它更新为play-services-location:11.8.0 So, i changed it in app build.gradle file and try sync but shows error 所以,我在应用程序build.gradle文件中更改了它,并尝试同步但显示错误
I'm new to android studio any help would be appreciated. 我是android studio的新手,将不胜感激。

older build.gradle(Module:app) 较旧的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) 新建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'
}

Try clicking 'add google maven repository and sync project' on the error message. 尝试在错误消息上单击“添加Google Maven存储库并同步项目”。

This should add google maven to your build.gradle file and fix the problem 这应该将google maven添加到您的build.gradle文件中并解决问题

We can add automatically the google maven repository by clicking ' add google maven repository and sync project' . 我们可以通过单击“ 添加google maven存储库并同步项目”来自动添加google maven存储库

But sometimes it doesn´t work so we need to add manually the google maven repository: 但是有时它不起作用,因此我们需要手动添加google maven存储库:

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

Example: 例:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM