Google云消息传递获取java.lang.IllegalArgumentException:已添加:Lcom / google / android / gms / gcm / GoogleCloudMessaging;

时间:2015-09-15 16:25:44

标签: android android-studio gradle google-cloud-messaging google-play-services

我正在尝试按照here的步骤在现有的Android应用中使用推送通知(使用Android工作室)。

当我添加以下依赖项编译'com.google.android.gms:play-services:7.5.0'时,gradle syncronization将永久持续(持续时间超过50分钟,甚至更多,因为我从来没有等到最后)。但是,当我把这种依赖性:编译'com.google.android.gms:play-services-gcm:7.5.0'时,它工作正常(持续约19分钟。这里有大约20个依赖项)项目)。

这些是这个项目中使用的一些依赖项:

    dependencies {
        compile 'com.android.support:support-v4:22.0.0'
        compile 'com.google.android:google-play-services:4.1.32'
        compile 'com.devsmart.android:devsmart-lib:1.0.0'
        compile 'com.jeremyfeinstein.slidingmenu.lib:sliding-menu:1.0.0'
        compile 'com.viewpagerindicator:viewpager-indicator:2.4.1'
        //compile 'com.google.android.gms:play-services:7.5.0'
        compile 'com.google.android.gms:play-services-gcm:7.5.0'
        compile 'com.google.android.gms:google-play-services_lib:4.1.32'
        //compile 'com.google.android.gms:play-services-maps:7.5.0'
        //compile 'com.google.android.gms:play-services-location:7.5.0'
        compile 'com.emilsjolander:sticky-list-headers:1.0.0'
        compile 'com.actionbarsherlock:actionbar-sherlock:4.2.0'
    .
    .
    .
        }

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    enforceUniquePackageName = false

    dexOptions {
        preDexLibraries = false
    }

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 19
    }
.
.
.

我知道我不止一次使用某些库(google play library):

compile 'com.google.android:google-play-services:4.1.32'
compile 'com.google.android.gms:google-play-services_lib:4.1.32'

但是如果没有它们,项目将无法工作,因为有些类对于这个项目很重要,而且改变它不是我的角色(只是为了在这个概念中集成推送通知)。

由于这两个库中没有GcmListenerService类(至少我收到错误它不存在)我必须放置另一个google play模块依赖项:

compile 'com.google.android.gms:play-services-gcm:7.5.0'

现在,当我把这种依赖并开始同步化时,除了我尝试运行应用程序之外,一切都工作正常。然后我收到了这个错误:

java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/gcm/GoogleCloudMessaging;
.
.
.Error:Execution failed for task ':CA:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1

0 个答案:

没有答案