android - Gradle 依赖排除不起作用

标签 android android-gradle-plugin build.gradle gradle-dependencies

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

关于android - Gradle 依赖排除不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35701570/

相关文章:

android - Gradle 无法解决 Android Studio 中的 Material 对话框依赖关系

android - 如何将 logcat 输出复制到剪贴板?

android - 无法实现 androidx.appcompat.appcompat :1. 0.0

java - GRADLE任务运行配置

gradle - gradle-外部jar文件中的引用

android - "Permission denied"在我自己的 Activity 中尝试处理来自浏览器的 "Share Image" Intent 时

java - 自定义 Lint 规则未在 eclipse/android studio 中列出

android - "The most simple Android project has the following build.gradle"

Android 无法在构建中重命名 aar 文件

java - 如何将另一个项目中的项目作为模块使用?