应用程序使用解析在测试推送通知上崩溃

时间:2014-10-04 14:44:25

标签: java android xml crash parse-platform

正如他们的推送通知快速入门指南所述,我做了一切。但每当我尝试发送测试推送时,应用程序崩溃。我已经完成了所有在线帮助资源,但除了执行之外,一切似乎都是正确的。

我的主要 - > Application.java

套餐的> com.virus.buzzkill;

public class BuzzKillApplication extends Application {

    @Override
    public void onCreate() {
          super.onCreate();
          Parse.initialize(this, "YhcMXhTCr65bWiI2RB4voL", "R7QWGNPMjIPh1CHTxZRXxuzgu");
          ParseInstallation.getCurrentInstallation().saveInBackground(); 

        }
}

我的AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.virus.buzzkill"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="19" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />


    <uses-feature
        android:name="android.hardware.camera"
        android:required="true" />



    <permission
        android:name="com.virus.buzzkill.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.virus.buzzkill.permission.C2D_MESSAGE" />

    <application
        android:name=".BuzzKillApplication"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".LoginActivity"
            android:label="@string/title_activity_login"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name=".SignUpActivity"
            android:label="@string/title_activity_sign_up"
            android:parentActivityName="com.virus..buzzkill.LoginActivity"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name=".EditFriendsActivity"
            android:label="@string/title_activity_edit_friends"
            android:parentActivityName=".MainActivity"
            android:screenOrientation="portrait" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.virus.buzzkill.MainActivity" />
        </activity>
        <activity
            android:name=".RecipientsActivity"
            android:label="@string/title_activity_recipients"
            android:parentActivityName=".MainActivity"
            android:screenOrientation="portrait" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.virus.buzzkill.MainActivity" />
        </activity>
        <activity
            android:name=".ViewImageActivity"
            android:label="@string/title_activity_view_image"
            android:parentActivityName=".MainActivity"
            android:screenOrientation="portrait" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.virus.buzzkill.MainActivity" />
        </activity>

        <service android:name="com.parse.PushService" />

        <receiver android:name="com.parse.ParseBroadcastReceiver" >
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.USER_PRESENT" />
            </intent-filter>
        </receiver>
        <receiver
            android:name="com.parse.ParsePushBroadcastReceiver"
            android:exported="false" >
            <intent-filter>
                <action android:name="com.parse.push.intent.RECEIVE" />
                <action android:name="com.parse.push.intent.DELETE" />
                <action android:name="com.parse.push.intent.OPEN" />
            </intent-filter>
        </receiver>
        <receiver
            android:name="com.parse.GcmBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

                <category android:name="com.virus.buzzkill" />
            </intent-filter>
        </receiver>
    </application>

</manifest>

logcat详细信息

 10-04 20:02:08.544: W/ActivityThread(16322): Application com.virus.buzzkill can be debugged on port 8100...
    10-04 20:02:08.860: I/Adreno-EGL(16322): <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LNX.LA.3.5.1_RB1.04.04.02.048.018_msm8226_LNX.LA.3.5.1_RB1__release_AU ()
    10-04 20:02:08.860: I/Adreno-EGL(16322): OpenGL ES Shader Compiler Version: E031.24.00.08
    10-04 20:02:08.860: I/Adreno-EGL(16322): Build Date: 03/07/14 Fri
    10-04 20:02:08.860: I/Adreno-EGL(16322): Local Branch: 
    10-04 20:02:08.860: I/Adreno-EGL(16322): Remote Branch: quic/LNX.LA.3.5.1_RB1.1
    10-04 20:02:08.860: I/Adreno-EGL(16322): Local Patches: NONE
    10-04 20:02:08.860: I/Adreno-EGL(16322): Reconstruct Branch: AU_LINUX_ANDROID_LNX.LA.3.5.1_RB1.04.04.02.048.018 + f2fd134 +  NOTHING
    10-04 20:02:08.911: D/OpenGLRenderer(16322): Enabling debug mode 0
    10-04 20:02:08.991: D/dalvikvm(16322): GC_FOR_ALLOC freed 480K, 46% free 9407K/17184K, paused 16ms, total 16ms
    10-04 20:02:09.025: I/dalvikvm-heap(16322): Grow heap (frag case) to 23.393MB for 12767920-byte allocation
    10-04 20:02:34.759: I/Activity(16322): Pritish
    10-04 20:02:36.055: D/dalvikvm(16322): GC_FOR_ALLOC freed 1629K, 25% free 22282K/29656K, paused 21ms, total 21ms
    10-04 20:02:50.597: D/AndroidRuntime(16322): Shutting down VM
    10-04 20:02:50.597: W/dalvikvm(16322): threadid=1: thread exiting with uncaught exception (group=0x4169cd40)
    10-04 20:02:50.600: E/AndroidRuntime(16322): FATAL EXCEPTION: main
    10-04 20:02:50.600: E/AndroidRuntime(16322): Process: com.virus.buzzkill, PID: 16322
    10-04 20:02:50.600: E/AndroidRuntime(16322): java.lang.RuntimeException: Unable to start receiver com.parse.ParsePushBroadcastReceiver: java.lang.NullPointerException
    10-04 20:02:50.600: E/AndroidRuntime(16322):    at android.app.ActivityThread.handleReceiver(ActivityThread.java:2441)
    10-04 20:02:50.600: E/AndroidRuntime(16322):    at android.app.ActivityThread.access$1700(ActivityThread.java:139)
    10-04 20:02:50.600: E/AndroidRuntime(16322):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1286)
    10-04 20:02:50.600: E/AndroidRuntime(16322):    at android.os.Handler.dispatchMessage(Handler.java:102)
    10-04 20:02:50.600: E/AndroidRuntime(16322):    at android.os.Looper.loop(Looper.java:136)
    10-04 20:02:50.600: E/AndroidRuntime(16322):    at android.app.ActivityThread.main(ActivityThread.java:5086)
    10-04 20:02:50.600: E/AndroidRuntime(16322):    at java.lang.reflect.Method.invokeNative(Native Method)
    10-04 20:02:50.600: E/AndroidRuntime(16322):    at java.lang.reflect.Method.invoke(Method.java:515)
    10-04 20:02:50.600: E/AndroidRuntime(16322):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
    10-04 20:02:50.600: E/AndroidRuntime(16322):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
    10-04 20:02:50.600: E/AndroidRuntime(16322):    at dalvik.system.NativeStart.main(Native Method)
    10-04 20:02:50.600: E/AndroidRuntime(16322): Caused by: java.lang.NullPointerException
    10-04 20:02:50.600: E/AndroidRuntime(16322):    at com.parse.ParsePushBroadcastReceiver.getSmallIconId(ParsePushBroadcastReceiver.java:253)
    10-04 20:02:50.600: E/AndroidRuntime(16322):    at com.parse.ParsePushBroadcastReceiver.getNotification(ParsePushBroadcastReceiver.java:335)
    10-04 20:02:50.600: E/AndroidRuntime(16322):    at com.parse.ParsePushBroadcastReceiver.onPushReceive(ParsePushBroadcastReceiver.java:143)
    10-04 20:02:50.600: E/AndroidRuntime(16322):    at com.parse.ParsePushBroadcastReceiver.onReceive(ParsePushBroadcastReceiver.java:104)
    10-04 20:02:50.600: E/AndroidRuntime(16322):    at android.app.ActivityThread.handleReceiver(ActivityThread.java:2434)
    10-04 20:02:50.600: E/AndroidRuntime(16322):    ... 10 more

解析通知的错误位于日志的最后一个条目中。 请帮助。

永远是新手。

3 个答案:

答案 0 :(得分:2)

在结束</application>标记之前立即将以下行添加到AndroidManifest.xml文件中:

    <meta-data android:name="com.parse.push.notification_icon" 
               android:resource="@drawable/push_icon"/>

其中push_icon是包中可绘制资源的名称。

答案 1 :(得分:0)

Parse和推送通知有一些奇怪的东西,我一直试图让它按照预期的方式正常工作(解析文档表明它会像你一样开箱即用,而你可以通过扩展ParsePushBroadcastReceiver来自定义推送通知handeling,但最终这样做是为了让它工作。

看看这个答案

https://stackoverflow.com/a/26180181/951448

您需要做什么:

  • 扩展ParsePushBroadcastReceiver类
  • 使用您的自定义类接收广播(在manifest.xml中)
  • 覆盖onPushOpen以手动打开您的活动(或按照您希望的方式处理通知的打开操作)。

答案 2 :(得分:0)

尝试将此行放在Application类中:

PushService.setDefaultPushCallback(this,YourAttivity.class);

此行应放在Parse.Initialize()语句之后。

试着让我知道。