java - App crashes when trying to run parse.com push notification application -
my parse push notification app seems crash whenever run it. double checked make sure permissions correct , build.gradle correct. created java class (which added src folder) parse application. here code parse application, android manifest, , build.gradle file.
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 android.mtp.mtpdatabase$1@3b5d3c26 registered here. missing call unregisterreceiver()? android.app.intentreceiverleaked: service com.android.providers.media.mtpservice has leaked intentreceiver android.mtp.mtpdatabase$1@3b5d3c26 registered here. missing call unregisterreceiver()? @ android.app.loadedapk$receiverdispatcher.<init>(loadedapk.java:1003) @ android.app.loadedapk.getreceiverdispatcher(loadedapk.java:767) @ android.app.contextimpl.registerreceiverinternal(contextimpl.java:1749) @ android.app.contextimpl.registerreceiver(contextimpl.java:1729) @ android.app.contextimpl.registerreceiver(contextimpl.java:1723) @ android.content.contextwrapper.registerreceiver(contextwrapper.java:488) @ android.mtp.mtpdatabase.setserver(mtpdatabase.java:619) @ android.mtp.mtpserver.<init>(mtpserver.java:33) @ com.android.providers.media.mtpservice.manageservicelocked(mtpservice.java:259) @ com.android.providers.media.mtpservice.onstartcommand(mtpservice.java:219) @ android.app.activitythread.handleserviceargs(activitythread.java:3072) @ android.app.activitythread.access$2100(activitythread.java:144) @ android.app.activitythread$h.handlemessage(activitythread.java:1470) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:155) @ android.app.activitythread.main(activitythread.java:5696) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1028) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:823)
if there information missing in logcat, please let me know. using phone run app, , gives many error messages other running processes in system. have turned parse-1.9.2.jar folder library, if helps @ all. have tried parse example @ https://parse.com/apps/quickstart#parse_push/android/native/existing hasn't worked either. can please help?
sincerely,
ani
firstly.
<uses-permission android:name="com.google.android.c2de.permission.receive"/>
should be:
<uses-permission android:name="com.google.android.c2dm.permission.receive"/>
c2dm
not c2de
also, in places use com.example.anish
, in others use com.example.ani
. should make sure consistent package defined in manifest/gradle.
in permission
, uses-permission
, broadcast receiver should consistent. in case setup should more like:
<!-- 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>
i've never used parse.com however, above based on understanding of google cloud messaging setup.
Comments
Post a Comment