简体   繁体   中英

GCM Push notification not working Android

I had a problem with push notification GCM in Android, the device is registered very well, I get the token, but when I send the notification, I get this error :

com.google.process.gapps W/GLSUser: [AppCertManager] IOException while requesting key: java.io.IOException: Invalid device key response. at com.google.android.gms.auth.be.appcert.aa(SourceFile:268) at com.google.android.gms.auth.be.appcert.aa(SourceFile:132) at com.google.android.gms.auth.be.appcert.ba(SourceFile:43) at com.google.android.gms.auth.bba(SourceFile:62) at com.google.android.gms.auth.baa(SourceFile:120) at com.google.android.gms.auth.baa(SourceFile:61) at com.google.android.gms.auth.be.cron.AuthCronService.a(SourceFile:44) at com.google.android.gms.gcm.au.run(SourceFile:140)

I test an other application it works fine, I don't know the main root of this problem.

this is my manifest :

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.paperpad.LaBouzerotte">



    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="${applicationId}.permission.MAPS_RECEIVE" />
    <uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
    <!-- App receives GCM messages. -->
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <!-- GCM connects to Google Services. -->
    <uses-permission android:name="android.permission.INTERNET" />
    <!-- GCM requires a Google account. -->
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <!-- Keeps the processor from sleeping when a message is received. -->
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <!-- Network State Permissions to detect Internet status -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <!-- Permission to vibrate -->
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.CALL_PHONE" />

    <uses-permission android:name="android.permission.READ_CALENDAR" />
    <uses-permission android:name="android.permission.WRITE_CALENDAR" />

    <uses-feature
        android:name="android.hardware.telephony"
        android:required="false" />

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <application

        android:theme="@style/AppTheme"
        android:allowBackup="true"
        android:allowClearUserData="true"
        android:hardwareAccelerated="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:largeHeap="true">
        <activity
            android:name="com.paperpad.skeleton.activities.MainActivity"
            android:label="@string/app_name" >

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>  <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyDB69SAK4uHXDFXzqdRvRCJ6zKDeS_UMRw" />  <receiver
            android:name="com.paperpad.LaBouzerotte.GcmBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <!-- Receives the actual messages. -->
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <category android:name="${applicationId}" />
            </intent-filter>
        </receiver>
        <service android:name="com.paperpad.LaBouzerotte.GcmIntentService" />
    </application>

</manifest>

and this is the build gradle content :

apply plugin: 'com.android.application'

buildscript {
    repositories {
        maven { url 'http://download.crashlytics.com/maven' }
    }

    dependencies {
        classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
    }
}
apply plugin: 'android'
apply plugin: 'crashlytics'

repositories {
    maven { url 'http://download.crashlytics.com/maven' }
}

android {

    dexOptions {

        preDexLibraries = false
    }
    lintOptions {
        abortOnError false
        checkReleaseBuilds false
    }

    useLibrary 'org.apache.http.legacy'

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }

    signingConfigs {
        debug_config {

        }
        release_config {


        }
    }
    compileSdkVersion 23
    buildToolsVersion '23.0.2'
    defaultConfig {
        applicationId "com.paperpad.skeleton"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 2
        versionName "0.2"
        signingConfig signingConfigs.debug_config
    }
    buildTypes {
        release {
            debuggable false
            //runProguard false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {

            debuggable true
            signingConfig signingConfigs.debug_config
            //renderscriptDebugBuild false
        }
    }
    productFlavors {
        Skeleton {
            applicationId "com.paperpad.skeleton"
            manifestPlaceholders = [activityLabel: "Skeleton", gcmPackage: "com.paperpad.skeleton"]
            minSdkVersion 15
            signingConfig signingConfigs.debug_config
            targetSdkVersion 23
            versionCode 2
            versionName "0.2"

        }
        SkeletonApps {
            applicationId "com.paperpad.LaBouzerotte"
            minSdkVersion 15
            signingConfig signingConfigs.debug_config
            targetSdkVersion 23
            versionCode 2
            versionName "0.2"

        }
    }

    sourceSets {

        Skeleton {

            /*java.srcDirs = ['main/java']
            resources.srcDirs = ['main/res']*/
            manifest.srcFile 'main/AndroidManifest.xml'
        }

        SkeletonApps {
            manifest.srcFile 'SkeletonApps/AndroidManifest.xml'
            resources.srcDirs = ['SkeletonApps/res']

        }
    }
}

dependencies {
    /*compile('com.android.support:support-v4:21.+') {
            exclude group: 'com.android.support', module: 'support-v4'
        }*/
    compile fileTree(dir: 'libs', include: ['*.jar'])
    /*compile files('libs/crashlytics.jar')*/
    //compile files('libs/gcm.jar')
    //compile files('libs/gcm-src.jar')
    compile files('libs/ormlite-android-4.45.jar')
    compile files('libs/ormlite-core-4.45.jar')
    compile files('libs/KenBurnsView-1.0.3.jar')
    compile files('libs/jackson-databind-2.1.4.jar')
    compile files('libs/jackson-core-2.1.4.jar')
    compile files('libs/jackson-annotations-2.1.4.jar')
    compile project(':progresswheel-master')
    //compile project(':volley')
    compile files('libs/json-simple-1.1.1.jar')
    compile 'com.android.support:appcompat-v7:23.1.1'
    //compile 'com.google.android.gms:play-services:8.3.0'
    compile 'com.mcxiaoke.volley:library:1.0.17'
    compile 'com.squareup.picasso:picasso:2.3.3'
    compile 'com.crashlytics.android:crashlytics:1.+'
    compile 'com.google.android.gms:play-services-gcm:8.3.0'
    compile 'com.google.android.gms:play-services-ads:8.3.0'
    compile files('libs/httpmime-4.1.jar')
}

Using Android studio 2.0 resolved the problem, I receive now the notification. Thank's for all.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM