2015-06-19 526 views
0

我的分析推送通知應用程序似乎在我運行時崩潰。我再次檢查以確保權限是正確的,並且我的build.gradle也是正確的。我爲解析應用程序創建了一個Java類(我將其添加到src文件夾中)。這裏是解析應用程序,我的Android Manifest和build.gradle文件的代碼。嘗試運行parse.com推送通知應用程序時,應用程序崩潰

的build.gradle FILE

buildscript { 
repositories { 
    mavenCentral() 
} 
dependencies { 
    classpath 'com.android.tools.build:gradle:1.2.3' 
} 
} 
apply plugin: 'com.android.application' 

android { 
compileSdkVersion 21 
buildToolsVersion "21.1.2" 

defaultConfig { 
    applicationId "com.example.anish.parseexample" 
    minSdkVersion 19 
    targetSdkVersion 21 
    versionCode 1 
    versionName "1.0" 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 
} 
dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    compile 'com.android.support:appcompat-v7:21.0.3' 
    compile files('libs/Parse-1.9.2.jar') 
} 

PARSEAPP.JAVA

package com.example.anish.parseexample; 

import android.app.Application; 

import com.parse.Parse; 
import com.parse.PushService; 

public class ParseApp extends Application { 
@Override 
public void onCreate() { 
    super.onCreate(); 
    Parse.initialize(this, "APP_ID_KEY_WAS_HERE", "CLIENT_ID_KEY_WAS_HERE"); 
    PushService.setDefaultPushCallback(this, MainActivity.class); 
} 
} 

的AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?> 

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

<permission android:protectionLevel="signature" android:name="com.example.ani.parseexample.ParseApp.permission.C2D_MESSAGE"/> 
<uses-permission android:name="com.example.ani.parseexample.ParseApp.permission.C2D_MESSAGE"/> 

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" 
    android:name=".ParseApp"> 
    <activity 
     android:name=".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> 
</application> 

<service android:name="com.parse.PushService"/> 
<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.example.ani.parseexample.ParseApp"/> 
    </intent-filter> 
</receiver> 

</manifest> 

logcat的

Service com.android.providers.media.MtpService has leaked IntentReceiver [email protected] that was originally registered here. Are you missing a call to unregisterReceiver()? 
android.app.IntentReceiverLeaked: Service com.android.providers.media.MtpService has leaked IntentReceiver [email protected] that was originally registered here. Are you missing a call to unregisterReceiver()? 
     at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:1003) 
     at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:767) 
     at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1749) 
     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1729) 
     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1723) 
     at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:488) 
     at android.mtp.MtpDatabase.setServer(MtpDatabase.java:619) 
     at android.mtp.MtpServer.<init>(MtpServer.java:33) 
     at com.android.providers.media.MtpService.manageServiceLocked(MtpService.java:259) 
     at com.android.providers.media.MtpService.onStartCommand(MtpService.java:219) 
     at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3072) 
     at android.app.ActivityThread.access$2100(ActivityThread.java:144) 
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470) 
     at android.os.Handler.dispatchMessage(Handler.java:102) 
     at android.os.Looper.loop(Looper.java:155) 
     at android.app.ActivityThread.main(ActivityThread.java:5696) 
     at java.lang.reflect.Method.invoke(Native Method) 
     at java.lang.reflect.Method.invoke(Method.java:372) 
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823) 

如果有一些信息在logcat中失蹤,請讓我知道。我正在使用手機來運行應用程序,並提供了有關係統中其他正在運行的進程的許多錯誤消息。如果有幫助,我已將Parse-1.9.2.jar文件夾轉換爲庫。我也嘗試了https://parse.com/apps/quickstart#parse_push/android/native/existing解析示例,但那也沒有奏效。有人可以幫忙嗎?

此致

阿尼

+0

發佈您登錄貓。 –

+0

添加logcat! –

回答

0

首先。

<uses-permission android:name="com.google.android.c2de.permission.RECEIVE"/> 

大概應該是:

<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/> 

c2dmc2de

此外,在您使用com.example.anish某些地方和別人對你使用com.example.ani。您應該確保您的清單/ gradle中定義的軟件包一致。

在你的permission,uses-permission和廣播接收器你應該是一致的。在你的情況你的設置應該更像:

<!-- lowercase these 2 --> 
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/ 
<!-- end lowercase --> 
... 
<permission android:protectionLevel="signature" android:name="com.example.anish.parseexample.permission.C2D_MESSAGE"/> 
<uses-permission android:name="com.example.anish.parseexample.permission.C2D_MESSAGE"/> 
... 
<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.example.ani.parseexample"/> 
    </intent-filter> 
</receiver> 

我從來沒有用過parse.com然而,上面的是根據我的google cloud messaging setup的理解。

相關問題