Android FirebaseCouldMessaging : FirebaseInstanceId background sync failed - SERVICE_NOT_AVAILABLE

匿名 (未验证) 提交于 2019-12-03 01:25:01

问题:

I have use Firebase Cloud Messaging(FCM) API for the push notification in Android. When I implemented that time perfect work but now it's can not find the Service of google play.

the error is:

FirebaseInstanceId: background sync failed: SERVICE_NOT_AVAILABLE,

Please help me how to resolve. I Have use below dependency in gradle file.

dependencies {     compile files('libs/ksoap2-android-assembly-3.4.0-jar.jar')     compile 'com.android.support:appcompat-v7:23.0.0'     compile files('libs/gson-2.2.4.jar')     compile files('libs/activation.jar')     compile files('libs/mail.jar')     compile files('libs/additionnal.jar')     compile 'com.android.support:multidex:1.0.1'     compile 'com.facebook.android:facebook-android-sdk:4.14.0'     compile 'com.google.firebase:firebase-messaging:9.0.2'      compile('com.google.android.gms:play-services:9.0.2') {         exclude group: "play-services-wallet"         exclude module: "play-services-wallet"         exclude group: "play-services-ads"         exclude module: "play-services-ads"     }  } 

Thanks for taking the time to read this.

回答1:

  1. Verify internet connectivity
  2. Verify if the Android SDK tools(Tools -> Android -> SDK manager -> SDK tools tab) has 'Google Play services' latest version and if not install the package. Then if you are using emulator, please stop the emulator and start it again.It works


回答2:

After long struggle i found the answer, if google play service is not running then FirebaseInstanceId background sync failed - SERVICE_NOT_AVAILABLE log print, so you can check your google play service is running properly or not ?

May be this information is helpful to you !



回答3:

You can check

  1. Check your internet connection with no proxy and open internet connect
  2. Replace your google-service.json with new one you can get this in firebaseconsol
  3. Please check your device has google play service in it and it working or not , firebase not work without google play service

Check -FireBaseInstanceId service does not get registered



回答4:

the service needs to be bound in the Manifest.xml

         

then one can access one single exposed method (the other names are obfuscated = not reliable):

package eu.acme.service;  import com.google.firebase.iid.FirebaseInstanceId; import com.google.firebase.iid.FirebaseInstanceIdService;  public class FireBaseInstanceIdService extends FirebaseInstanceIdService {      @Override     @android.support.annotation.WorkerThread     public void onTokenRefresh() {          /* obtain the current InstanceId token: */         String token = FirebaseInstanceId.getInstance().getToken();     } } 

one could only work around it, by not provoking it, eg. by not adding any AuthState Listener while knowing that there is no active network present, as explained here - as it seems, one otherwise cannot catch the exception thrown from within the library - which can be ignored, since it merely just complains, that there is no network connectivity.

com.google.android.gms.iid and com.google.firebase.iid are about the same.



回答5:

Easiest solution is to delete the bin and obj folders under the .Droid directory.
In this way you have a clean start every time.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!