gradle 中的不兼容库

Incompatible libraries in gradle

我想在我的应用程序中使用 gcm,但是在 gradle 文件中添加依赖项时我遇到了不兼容库的错误。 我的应用级别 gradle 文件具有如下依赖关系 ..

apply plugin: 'com.google.gms.google-services'
 .
 .
 .
 .
 .
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.okhttp:okhttp:2.6.0'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'com.squareup.okhttp:logging-interceptor:2.6.0'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'com.appvirality:AppviralityUI:1.1.18+'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
}

并且我添加了 classpath 'com.google.gms:google-services:1.5.0-beta2' 在我的项目级别 gradle.

我的 google 播放服务已更新到最新版本,但仍然显示类似...的错误 所有库必须使用完全相同的版本规范。 检查后我知道它与 compile 'com.appvirality:AppviralityUI:1.1.18+' 库冲突。

谢谢

首先你需要改变这个

apply plugin: 'com.google.gms.google-services'

使用

apply plugin: 'com.android.application'

您可以将 类路径 设置为 classpath 'com.android.tools.build:gradle:1.5.0'

不知道如何..但是,只需将编译 'com.google.android.gms:play-services-gcm:8.3.0' 更改为 compile 'com.google.android.gms:play-services:8.3.0'

就可以了