Reputation: 105
I had an app using Firebase and GMS service with version 11.8.0 for 2 years and now, I want to upgrade to latest version is 17.0.0. The dependencies following by below in gradle:
Before upgrade:
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.android.gms:play-services-location:11.8.0'
implementation 'com.google.android.gms:play-services-base:11.8.0'
implementation 'com.google.firebase:firebase-invites:11.8.0'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
implementation 'com.google.firebase:firebase-config:11.8.0'
implementation 'com.google.android.gms:play-services-maps:11.8.0'
After upgrade:
implementation 'com.google.firebase:firebase-analytics:17.2.3'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-base:17.1.0'
implementation 'com.google.firebase:firebase-invites:17.0.0'
implementation 'com.google.firebase:firebase-messaging:20.1.1'
implementation 'com.google.firebase:firebase-config:19.1.2'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
And modify code from:
public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {
@Override
public void onTokenRefresh() {
//Getting registration token
String token = FirebaseInstanceId.getInstance().getToken();
// Save token
}
}
To
public class MyFirebaseInstanceIDService extends FirebaseMessagingService {
@Override
public void onNewToken(@NonNull String s) {
super.onNewToken(s);
// Save token
}
}
And in Manifest I keep register service as below:
<service android:name=".notification.MyFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
Everything else I setup before is no change. But when build and run I take an error with below stacktrace:
2020-03-12 11:38:29.225 26475-26543/com.example E/FirebaseInstanceId: Topic sync or token retrieval failed on hard failure exceptions: FIS_AUTH_ERROR. Won't retry the operation.
2020-03-12 11:38:29.460 26475-26550/com.example E/FirebaseInstanceId: Failed to get FIS auth token
java.util.concurrent.ExecutionException: com.google.firebase.installations.FirebaseInstallationsException
at com.google.android.gms.tasks.Tasks.zzb(Unknown Source:61)
at com.google.android.gms.tasks.Tasks.await(Unknown Source:23)
at com.google.firebase.iid.zzs.zzb(com.google.firebase:firebase-iid@@20.1.0:54)
at com.google.firebase.iid.zzs.zza(com.google.firebase:firebase-iid@@20.1.0:89)
at com.google.firebase.iid.zzv.run(Unknown Source:12)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
Caused by: com.google.firebase.installations.FirebaseInstallationsException
at com.google.firebase.installations.FirebaseInstallations.doRegistrationInternal(com.google.firebase:firebase-installations@@16.0.0:333)
at com.google.firebase.installations.FirebaseInstallations.doGetId(com.google.firebase:firebase-installations@@16.0.0:280)
at com.google.firebase.installations.FirebaseInstallations.access$lambda$0(Unknown Source:0)
at com.google.firebase.installations.FirebaseInstallations$$Lambda$1.run(Unknown Source:2)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
After looking for solution on google, i found something like this: https://firebase.google.com/support/release-notes/android#2020-03-03
Then I go to my firebase console and enable Firebase Installation but nothing change. So can someone help me find out the way to resolve this issue? Many thank to all!
Upvotes: 5
Views: 12140
Reputation: 19250
Downgrading the firebase-messaging library is not a recommended solution.
As of v20.1.1 of Firebase cloud messaging and 20.1.0 of Firebase InstanceId, these libraries depends on the Firebase installations SDK. This make things a little bit different than before.
For instance if you use FirebaseOptions
and not a google-services.json
file to intialize these libraries, you need extra information to pass to FirebaseOptions
.
According to the release note:
Apps that use the Firebase auto-initialization process and the Gradle plugin to convert google-services.json into resources are unaffected. However, apps that create their own FirebaseOptions instances must provide a valid API key, Firebase project ID, and application ID.
Reference: Firebase android release note
TL; DR
So to sum up, you should look for breaking changes that affect your code and update them the way the latest version supports.
Upvotes: 3
Reputation: 6552
Firebase Android SDK updates on February 27 (M65) and afterwards introduced a new infrastructure service, the Firebase Installations SDK which comes with a dependency on the Firebase Installations API.
Firebase Installations requires valid Firebase options API key
, project ID
, and application ID
(a.k.a. "appId
") in order to successfully communicate with Firebase servers.
Errors during communication with the Firebase Installations API indicate invalid Firebase options or misconfigurations regarding API keys.
To mitigate the issue
google-services.json
file from your Firebase console:
Firebase options: instructions and background.Application restrictions
: Either set the radio button to None
or make sure that your app is white-listed (with the correct SHA-1 certificate
).For details, please visit:
https://firebase.google.com/support/privacy/init-options
Upvotes: 0
Reputation: 2366
change firebase-messaging
version to 20.1.0
implementation 'com.google.firebase:firebase-messaging:20.1.0'
Upvotes: 7