GCM推送通知无法运行Android

时间:2015-12-07 10:33:13

标签: android push-notification google-cloud-messaging

我在Android中推送通知GCM时遇到问题,设备注册得很好,我得到令牌,但是当我发送通知时,我收到此错误:

  

com.google.process.gapps W / GLSUser:[AppCertManager] IOException while   请求密钥:                                                                        java.io.IOException:设备密钥响应无效。                                                                           在com.google.android.gms.auth.be.appcert.a.a(SourceFile:268)                                                                           在com.google.android.gms.auth.be.appcert.a.a(SourceFile:132)                                                                           在com.google.android.gms.auth.be.appcert.b.a(SourceFile:43)                                                                           在com.google.android.gms.auth.b.b.a(SourceFile:62)                                                                           在com.google.android.gms.auth.b.a.a(SourceFile:120)                                                                           在com.google.android.gms.auth.b.a.a(SourceFile:61)                                                                           在   com.google.android.gms.auth.be.cron.AuthCronService.a(的SourceFile:44)                                                                           在com.google.android.gms.gcm.au.run(SourceFile:140)

我测试其他应用程序工作正常,我不知道这个问题的主要根源。

这是我的清单:

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

这是构建gradle内容:

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')
}

1 个答案:

答案 0 :(得分:0)

使用Android studio 2.0解决了这个问题,我现在收到了通知。 谢谢所有人。