可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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:
- Verify internet connectivity
- 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
- Check your internet connection with no proxy and open internet connect
- Replace your
google-service.json
with new one you can get this in firebaseconsol - 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.