我的分析推送通知應用程序似乎在我運行時崩潰。我再次檢查以確保權限是正確的,並且我的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解析示例,但那也沒有奏效。有人可以幫忙嗎?
此致
阿尼
發佈您登錄貓。 –
添加logcat! –