android - Unable to connect to Firebase Cloud Messaging -
i'm trying unable connect firebase cloud mssaging service. below error:
background sync failed: service_not_available, retry in 320s
and many more. here log cat:
09-12 23:56:34.682 24569-24613/aboundinfo.mzkhan.firebaseapp i/openglrenderer: initialized egl, version 1.4 09-12 23:56:34.712 24569-24613/aboundinfo.mzkhan.firebaseapp i/openglrenderer: hwui protection enabled context , &this =0xa0922088 ,&megldisplay = 1 , &meglconfig = 8 09-12 23:56:34.712 24569-24613/aboundinfo.mzkhan.firebaseapp d/openglrenderer: enabling debug mode 0 09-12 23:56:34.852 24569-24569/aboundinfo.mzkhan.firebaseapp i/timeline: timeline: activity_idle id: android.os.binderproxy@305676cc time:224172576 09-12 23:56:34.862 24569-24615/aboundinfo.mzkhan.firebaseapp d/firebaseinstanceid: background sync failed: service_not_available, retry in 10s 09-12 23:56:39.662 24776-24776/aboundinfo.mzkhan.firebaseapp:background_crash d/resourcesmanager: creating new assetmanager , set /data/app/aboundinfo.mzkhan.firebaseapp-2/base.apk 09-12 23:56:39.862 24776-24776/aboundinfo.mzkhan.firebaseapp:background_crash w/dynamitemodule: local module descriptor class com.google.android.gms.crash not found. 09-12 23:56:39.912 24776-24776/aboundinfo.mzkhan.firebaseapp:background_crash d/resourcesmanager: creating new assetmanager , set /data/app/com.google.android.gms-1/base.apk 09-12 23:56:39.912 24776-24776/aboundinfo.mzkhan.firebaseapp:background_crash w/resourcesmanager: asset path '/system/framework/com.android.media.remotedisplay.jar' not exist or contains no resources. 09-12 23:56:39.912 24776-24776/aboundinfo.mzkhan.firebaseapp:background_crash w/resourcesmanager: asset path '/system/framework/com.android.location.provider.jar' not exist or contains no resources. 09-12 23:56:39.972 24776-24776/aboundinfo.mzkhan.firebaseapp:background_crash d/chimeracfgmgr: reading stored module config 09-12 23:56:40.002 24776-24776/aboundinfo.mzkhan.firebaseapp:background_crash i/dynamitemodule: considering local module com.google.android.gms.crash:0 , remote module com.google.android.gms.crash:3 09-12 23:56:40.002 24776-24776/aboundinfo.mzkhan.firebaseapp:background_crash i/dynamitemodule: selected remote version of com.google.android.gms.crash, version >= 3 09-12 23:56:40.032 24776-24776/aboundinfo.mzkhan.firebaseapp:background_crash d/chimerafileapk: primary abi of requesting process armeabi-v7a 09-12 23:56:40.032 24776-24776/aboundinfo.mzkhan.firebaseapp:background_crash i/art: dexfile_isdexoptneeded failed open oat file '/data/dalvik-cache/arm/data@data@com.google.android.gms@app_chimera@m@00000008@dynamitemodulesc_gmscore_prodlmp_xxhdpi_release.apk@classes.dex' file location '/data/data/com.google.android.gms/app_chimera/m/00000008/dynamitemodulesc_gmscore_prodlmp_xxhdpi_release.apk': failed open oat filename reading: no such file or directory 09-12 23:56:40.032 24776-24776/aboundinfo.mzkhan.firebaseapp:background_crash d/chimerafileapk: classloading successful. optimized code found. 09-12 23:56:40.042 24776-24776/aboundinfo.mzkhan.firebaseapp:background_crash i/firebasecrashreceiverserviceimpl: firebasecrashreceiverserviceimpl created classloader com.google.android.chimera.container.internal.delegatelastpathclassloader[dexpathlist[[zip file "/data/data/com.google.android.gms/app_chimera/m/00000008/dynamitemodulesc_gmscore_prodlmp_xxhdpi_release.apk"],nativelibrarydirectories=[/vendor/lib, /system/lib]]] 09-12 23:56:40.042 24776-24776/aboundinfo.mzkhan.firebaseapp:background_crash d/firebasecrashreceiverserviceimpl: oncreate 09-12 23:56:40.092 24776-24776/aboundinfo.mzkhan.firebaseapp:background_crash i/dynamitemodule: considering local module com.google.android.gms.flags:0 , remote module com.google.android.gms.flags:1 09-12 23:56:40.092 24776-24776/aboundinfo.mzkhan.firebaseapp:background_crash i/dynamitemodule: selected remote version of com.google.android.gms.flags, version >= 1 09-12 23:56:40.172 24776-24776/aboundinfo.mzkhan.firebaseapp:background_crash i/firebasecrashsenderserviceimpl: firebasecrashsenderserviceimpl created classloader com.google.android.chimera.container.internal.delegatelastpathclassloader[dexpathlist[[zip file "/data/data/com.google.android.gms/app_chimera/m/00000008/dynamitemodulesc_gmscore_prodlmp_xxhdpi_release.apk"],nativelibrarydirectories=[/vendor/lib, /system/lib]]] 09-12 23:56:40.172 24776-24776/aboundinfo.mzkhan.firebaseapp:background_crash d/firebasecrashsenderserviceimpl: oncreate 09-12 23:56:44.732 24569-24592/aboundinfo.mzkhan.firebaseapp w/dynamitemodule: local module descriptor class com.google.firebase.auth not found. 09-12 23:56:44.972 24569-25015/aboundinfo.mzkhan.firebaseapp d/firebaseinstanceid: background sync failed: service_not_available, retry in 20s 09-12 23:57:05.042 24569-25603/aboundinfo.mzkhan.firebaseapp d/firebaseinstanceid: background sync failed: service_not_available, retry in 40s 09-12 23:57:45.172 24569-26405/aboundinfo.mzkhan.firebaseapp d/firebaseinstanceid: background sync failed: service_not_available, retry in 80s 09-12 23:59:21.432 24569-28178/aboundinfo.mzkhan.firebaseapp d/firebaseinstanceid: background sync failed: service_not_available, retry in 160s 09-13 00:02:10.832 24569-31836/aboundinfo.mzkhan.firebaseapp d/firebaseinstanceid: background sync failed: service_not_available, retry in 320s 09-13 00:02:34.662 24569-24569/aboundinfo.mzkhan.firebaseapp v/activitythread: updatevisibility : activityrecord{3239ee18 token=android.os.binderproxy@305676cc {aboundinfo.mzkhan.firebaseapp/aboundinfo.mzkhan.firebaseapp.mainactivity}} show : false 09-13 00:02:34.662 24569-24569/aboundinfo.mzkhan.firebaseapp d/firebaseapp: notifying background state change listeners. 09-13 00:02:34.842 24569-32479/aboundinfo.mzkhan.firebaseapp i/dynamitemodule: considering local module com.google.android.gms.tagmanager:3 , remote module com.google.android.gms.tagmanager:3 09-13 00:02:34.842 24569-32479/aboundinfo.mzkhan.firebaseapp i/dynamitemodule: selected local version of com.google.android.gms.tagmanager 09-13 00:02:34.932 24569-32479/aboundinfo.mzkhan.firebaseapp w/googletagmanager: tag manager's event handler not installed (no container loaded) 09-13 00:02:34.932 24569-32479/aboundinfo.mzkhan.firebaseapp i/googletagmanager: tag manager initilization took 66ms 09-13 00:02:56.442 24569-24569/aboundinfo.mzkhan.firebaseapp d/firebaseapp: notifying background state change listeners. 09-13 00:02:56.502 24569-24569/aboundinfo.mzkhan.firebaseapp i/timeline: timeline: activity_idle id: android.os.binderproxy@305676cc time:224554224
public class myfirebaseinstanceidservice extends firebaseinstanceidservice { private static final string tag = "myfirebaseiidservice"; @override public void ontokenrefresh() { //getting registration token string refreshedtoken = firebaseinstanceid.getinstance().gettoken(); //displaying token on logcat log.d(tag, "refreshed token: " + refreshedtoken); } private void sendregistrationtoserver(string token) { //you can implement method store token on server //not required current project } }
public class myfirebasemessagingservice extends firebasemessagingservice { private static final string tag = "myfirebasemsgservice"; @override public void onmessagereceived(remotemessage remotemessage) { //displaying data in log //it optional log.d(tag, "from: " + remotemessage.getfrom()); log.d(tag, "notification message body: " + remotemessage.getnotification().getbody()); //calling method generate notification sendnotification(remotemessage.getnotification().getbody()); } //this method generating push notification //it same did in earlier posts private void sendnotification(string messagebody) { intent intent = new intent(this, mainactivity.class); intent.addflags(intent.flag_activity_clear_top); pendingintent pendingintent = pendingintent.getactivity(this, 0, intent, pendingintent.flag_one_shot); uri defaultsounduri= ringtonemanager.getdefaulturi(ringtonemanager.type_notification); notificationcompat.builder notificationbuilder = new notificationcompat.builder(this) .setsmallicon(r.mipmap.ic_launcher) .setcontenttitle("firebase push notification") .setcontenttext(messagebody) .setautocancel(true) .setsound(defaultsounduri) .setcontentintent(pendingintent); notificationmanager notificationmanager = (notificationmanager) getsystemservice(context.notification_service); notificationmanager.notify(0, notificationbuilder.build()); } }
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="aboundinfo.mzkhan.firebaseapp"> <uses-permission android:name="android.permission.internet"/> <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsrtl="true" android:theme="@style/apptheme"> <activity android:name=".mainactivity"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <service android:name=".firebase.myfirebasemessagingservice" > <intent-filter> <action android:name="com.google.firebase.messaging_event"/> </intent-filter> </service> <service android:name=".firebase.myfirebaseinstanceidservice"> <intent-filter> <action android:name="com.google.firebase.instance_id_event"/> </intent-filter> </service> </application> </manifest>
my gradle:
apply plugin: 'com.android.application' android { compilesdkversion 24 buildtoolsversion "24.0.2" defaultconfig { applicationid "aboundinfo.mzkhan.firebaseapp" minsdkversion 16 targetsdkversion 24 versioncode 1 versionname "1.0" multidexenabled true } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile filetree(dir: 'libs', include: ['*.jar']) testcompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:24.2.0' compile 'com.google.firebase:firebase-core:9.4.0' compile 'com.google.firebase:firebase-messaging:9.4.0' compile 'com.google.android.gms:play-services:9.4.0' compile 'com.google.firebase:firebase-analytics:9.0.0' } apply plugin: 'com.google.gms.google-services'
have added 2 service in manifest?
<service android:name=".gcm.customfcmlistenerservice"> <intent-filter> <action android:name="com.google.firebase.messaging_event" /> </intent-filter> </service> <service android:name=".gcm.myinstanceidfireservice"> <intent-filter> <action android:name="com.google.firebase.instance_id_event" /> </intent-filter> </service>
Comments
Post a Comment