Reputation: 1064
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.
Upvotes: 37
Views: 54054
Reputation: 1
You need to update your play services and make sure your internet connectivity is good.
Upvotes: 0
Reputation: 1376
In my case
I have been Added google-services.json
file in Project root, I moved it to app folder and problem has been fixed.
MyProjectRootDir/google-services.json
move to -->
MyProjectRootDir/app/google-services.json
Upvotes: -1
Reputation: 377
I just had this problem. In my case, only worked when I stopped the emulator, closed it, and opened again. I didn't make any other changes.
Upvotes: 5
Reputation: 41
Me too had the same issue, resolved by just Clean Project option under build. Hope it might help anyone here.
Upvotes: 1
Reputation: 8315
Connect your mobile with different wifi connection with different service provider. It seems weird but you can try it!
Upvotes: 2
Reputation: 81
In my case - I rebooted my PC and it worked.
Im not an expert, so I might have covered one of the mentioned tipps by my approach
Upvotes: 2
Reputation: 485
In my case, I just removed instant run from Android Studio preferences
Upvotes: 1
Reputation: 543
Easiest solution is to delete the bin and obj folders under the .Droid directory.
In this way you have a clean start every time.
Upvotes: 2
Reputation: 3835
You can check
google-service.json
with new one you can get this in firebaseconsolCheck -FireBaseInstanceId service does not get registered
Upvotes: 15
Reputation: 221
Upvotes: 22
Reputation: 76789
the service needs to be bound in the Manifest.xml
<!-- Firebase InstanceId Service -->
<service
android:name="eu.acme.service.FireBaseInstanceIdService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
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.
Upvotes: 5
Reputation: 6509
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 !
Upvotes: 7