添加google plya-services时,所有com.android.support库都必须使用完全相同的版本规范 [英] all com.android.support libraries must use the exact same version specification when adding google plya-services

查看:98
本文介绍了添加google plya-services时,所有com.android.support库都必须使用完全相同的版本规范的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在添加google play-services库时,我可以在地图中添加此错误:

When adding google play-services library so I can add in a map I got this error:

所有com.android.support库必须使用完全相同的版本规范

all com.android.support libraries must use the exact same version specification

我的依赖项如下:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.google.android.gms:play-services:+'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'de.hdodenhof:circleimageview:2.1.0'
}

我尝试更改android support版本和android play services版本,但错误仍然存​​在.

I tried to change the android support version as well as the android play services version, but the error remained.

推荐答案

使用恒定版本,删除+:

implementation 'com.google.android.gms:play-services:15.0.1'

还要避免添加整个API,仅选择所需的API,就可以找到它们这里.例如,如果您知道只需要Google Maps,则只需添加以下内容:

And also avoid adding the whole API, choose only the one that you need, you can find them here. For example, if you know you will only need Google Maps then just add this:

implementation 'com.google.android.gms:play-services-maps:15.0.1'

而不是像您一样整个事情.

Instead of the whole thing like you did.

将此添加到您的项目构建gradle文件(而不是模块1):

Add this to your project build gradle file (not the module one):

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

这篇关于添加google plya-services时,所有com.android.support库都必须使用完全相同的版本规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆