Gradle 依赖项排除不起作用

Gradle dependency exclusion not working

我的项目 build.gradle 依赖项是:

dependencies {
    ...
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'com.google.android.gms:play-services-maps:8.4.0'
    compile 'com.google.android.gms:play-services-analytics:8.4.0'
    compile 'com.google.android.gms:play-services-appinvite:8.4.0'
    compile 'com.google.android.gms:play-services-gcm:8.4.0'

    compile 'co.realtime:messaging-android:2.1.58'
}

并且 co.realtime:messageing-android build.gradle 依赖项是:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile ('com.android.support:appcompat-v7:21.0.3'){
        transitive = true;
    }
    compile ('com.google.android.gms:play-services:6.1.71'){
        transitive = true;
    }
    compile ('com.googlecode.json-simple:json-simple:1.1'){
        transitive = true;
    }
}

如果我尝试编译我的项目,我会收到以下错误:

Error:Gradle: Execution failed for task ':app-module:processProdDebugResources'. Error: more than one library with package name 'com.google.android.gms' You can temporarily disable this error with android.enforceUniquePackageName=false However, this is temporary and will be enforced in 1.0

如果我使用 enforceUniquePackageName(false) 我得到:

cannot resolve symbol to GoogleCloudMessaging.INSTANCE_ID_SCOPE

所以我想我必须通过管理依赖关系来解决这个问题。我试过:

compile ('co.realtime:messaging-android:2.1.58'){
        exclude module: 'com.google'
}

compile ('co.realtime:messaging-android:2.1.58'){
        exclude group: 'com.google.android.gms', module: 'play-services-gcm'
}

但没有任何接缝工作...我该如何解决这个问题?
谢谢。

问题出在 'play-services-gcm' 而不是 'play-services'

compile ('co.realtime:messaging-android:2.1.58'){
        exclude group: 'com.google.android.gms', module: 'play-services'
}

grrr 那些打字错误...好吧,我想我可以删除这个问题,但是,偶尔会有人遇到同样的问题,所以我会把它留在这里,希望它能帮助有需要的人。