0

I am trying to integrate Push notifications in an existing Android app (using Android studio) following steps from here.

When I add the following dependency compile 'com.google.android.gms:play-services:7.5.0', gradle syncronization lasts forever (lasts more than 50 minutes, even more since I never waited till the end). But when I put this depencency: compile 'com.google.android.gms:play-services-gcm:7.5.0' it works fine (lasts about 19 minutes. There are about 20 dependencies in this project).

Those are some of the dependencies that are used in this project:

    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
    }
.
.
.

I know that I am using some libraries more than once (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'

But project won't work without them, since some classes are important to this project, and it is not my role to change it (just to integrate push notifications in this concept).

Since non of those two libraries have GcmListenerService class (at least I am getting error it doesn't exist) I have to put another google play module dependency:

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

And now, when i put this dependency and start syncorinization, everything works fine and smooth, except when I try to run the application. Then I get this error:

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
Glimpse
  • 392
  • 5
  • 20
  • why are you using and old and new version of google play services? – tyczj Sep 15 '15 at 17:11
  • Newer version of google play services doesn't have some classes that are used in this project. This is not my project, it is not my job to change all that classes to use GoogleApiService instead of some others etc...I must integrate Push notifications without changing other things... – Glimpse Sep 15 '15 at 17:45
  • what are the classes that you say are not included? If you need to integrate GCM and properly upgrading breaks other things then you need to tell the person whose project it is that they need to fix that before you can properly do your work. Bottom line you cannot have 2 versions of google play services – tyczj Sep 15 '15 at 17:46
  • It's not a person, it's a company. You can have two same libraries but different versions if their package name is different, example: com.google.android:google-play-services:4.1.32 and com.google.android.gms:google-play-services_lib:4.1.32. I have found some kind of solution here:http://stackoverflow.com/questions/21764128/how-do-i-exclude-all-instances-of-a-transitive-dependency-when-using-gradle. But it didn't help me... – Glimpse Sep 15 '15 at 18:47
  • Showing more of the error would help. I think you should suggest sorting out the Google Play Services duplication issue before adding GCM. You could look into packagingOptions in the android gradle plugin to exclude duplicate classes. – Arthur Thompson Sep 17 '15 at 04:11

0 Answers0