0

My app.gradle

 apply plugin: 'com.android.application'
    apply plugin: 'android-apt'
    apply plugin: 'com.google.gms.google-services'
    android {
        compileSdkVersion 24
        buildToolsVersion "24.0.2"
        defaultConfig {
            applicationId "com.mss.plix"
            minSdkVersion 16
            targetSdkVersion 24
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
            multiDexEnabled true
        }
        //====================Add below two line=============
        dexOptions {
            javaMaxHeapSize "4g" //specify the heap size for the dex process
            preDexLibraries = false //delete the already predexed libraries
        }

        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

    ext {
        permissionsDispatcherVersion = '2.1.2'
    }
    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
        compile 'de.hdodenhof:circleimageview:2.0.0'
        compile 'com.jakewharton:butterknife:7.0.1'
        testCompile 'junit:junit:4.12'
        compile 'de.hdodenhof:circleimageview:2.0.0'
        compile 'com.isseiaoki:simplecropview:1.1.4'
        compile 'com.github.hotchemi:permissionsdispatcher:2.1.3'
        compile 'com.github.aakira:expandable-layout:1.4.1@aar'
        compile 'com.github.hotchemi:permissionsdispatcher:2.1.3'
        apt "com.github.hotchemi:permissionsdispatcher-processor:2.1.3"
        compile project(':library')
       compile 'com.android.support:appcompat-v7:24.2.0'
       compile 'com.android.support:design:24.2.0'
        compile 'com.android.support:recyclerview-v7:24.2.0'
        compile 'com.android.support:cardview-v7:24.2.0'
        compile 'com.google.code.gson:gson:2.6.2'
        compile 'com.squareup.retrofit2:retrofit:2.0.2'
        compile 'com.squareup.retrofit2:converter-gson:2.0.2'
        compile 'com.squareup.okhttp:okhttp:2.5.0'
        compile 'com.android.support:multidex:1.0.1'
        compile 'com.google.android.gms:play-services:9.0.0'
        compile 'com.android.support:support-v4:24.2.1'


    }



    repositories {
        jcenter()
    }

My Project Gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0-rc2'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        classpath 'com.google.gms:google-services:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

My Log output when trying to get token

E/UncaughtException: java.lang.IncompatibleClassChangeError: android.support.v4.content.ContextCompat
                                                          at com.google.android.gms.iid.zzd.zzeC(Unknown Source)
                                                          at com.google.android.gms.iid.zzd.<init>(Unknown Source)
                                                          at com.google.android.gms.iid.zzd.<init>(Unknown Source)
                                                          at com.google.android.gms.iid.InstanceID.zza(Unknown Source)
                                                          at com.google.android.gms.iid.InstanceID.getInstance(Unknown Source)
                                                          at com.mss.plix.Notifications.GCMRegistrationIntentService.registerGCM(GCMRegistrationIntentService.java:43)
                                                          at com.mss.plix.Notifications.GCMRegistrationIntentService.onHandleIntent(GCMRegistrationIntentService.java:30)
                                                          at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
                                                          at android.os.Handler.dispatchMessage(Handler.java:102)
                                                          at android.os.Looper.loop(Looper.java:136)
                                                          at android.os.HandlerThread.run(HandlerThread.java:61)

I am implementing Push notification in my app, but when I am calling GcmIntentService, I'm getting the error that I have already posted in my log output. I also tried using FCM but getting the same issue. If anyone has implemented this, then please help. Thanks in advance.

Spartak Team
  • 81
  • 3
  • 13
  • Have you seen this related question: http://stackoverflow.com/q/37312340/4815718 ? The problem may be related to incompatible versions of the libraries. One answer at the linked question was to upgrade to `com.google.android.gms:play-services:9.0.1`. Also, you will be better build performance and smaller APK if you only include the Play Services and Firebase libraries you actually need. Including `com.google.android.gms:play-services:9.x.x.` adds them all. – Bob Snyder Sep 16 '16 at 15:01

1 Answers1

0

**> Got Answer of my question the error is because of using play service

9.0.0

But when we update the play service to 9.4.0 and same as firebase dependency .and the main issue in my gradle is apply plugin: 'com.google.gms.google-services' will not come at the top of gradle it will come at the bottom after dependency .And i dont know why this works fine and my token and context compact issue also got resolved.**

apply plugin: 'com.android.application'
    apply plugin: 'android-apt'

    android {
        compileSdkVersion 24
        buildToolsVersion "24.0.2"
        defaultConfig {
            applicationId "com.mss.plix"
            minSdkVersion 16
            targetSdkVersion 24
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
            multiDexEnabled true
        }
        //====================Add below two line=============
        dexOptions {
            javaMaxHeapSize "4g" //specify the heap size for the dex process
            preDexLibraries = false //delete the already predexed libraries
        }

        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

    ext {
        permissionsDispatcherVersion = '2.1.2'
    }
    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
        compile 'de.hdodenhof:circleimageview:2.0.0'
        compile 'com.jakewharton:butterknife:7.0.1'
        testCompile 'junit:junit:4.12'
        compile 'de.hdodenhof:circleimageview:2.0.0'
        compile 'com.isseiaoki:simplecropview:1.1.4'
        compile 'com.github.hotchemi:permissionsdispatcher:2.1.3'
        compile 'com.github.aakira:expandable-layout:1.4.1@aar'
        compile 'com.github.hotchemi:permissionsdispatcher:2.1.3'
        apt "com.github.hotchemi:permissionsdispatcher-processor:2.1.3"
        compile project(':library')
       compile 'com.android.support:appcompat-v7:24.2.0'
       compile 'com.android.support:design:24.2.0'
        compile 'com.android.support:recyclerview-v7:24.2.0'
        compile 'com.android.support:cardview-v7:24.2.0'
        compile 'com.google.code.gson:gson:2.6.2'
        compile 'com.squareup.retrofit2:retrofit:2.0.2'
        compile 'com.squareup.retrofit2:converter-gson:2.0.2'
        compile 'com.squareup.okhttp:okhttp:2.5.0'
        compile 'com.android.support:multidex:1.0.1'
        compile 'com.google.android.gms:play-services:9.0.0'
        compile 'com.android.support:support-v4:24.2.1'


    }

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

    repositories {
        jcenter()
    }

it should be like this . :)

Spartak Team
  • 81
  • 3
  • 13