androidfirebaseioexception

java.io.IOException: FIS_AUTH_ERROR in Android Firebase


I'm getting following error with Firebase services.

 E/FirebaseInstanceId: Topic sync or token retrieval failed on hard failure exceptions: FIS_AUTH_ERROR. Won't retry the operation.
 D/AndroidRuntime: Shutting down VM
    com.google.android.gms.tasks.RuntimeExecutionException: java.io.IOException: FIS_AUTH_ERROR
        at com.google.android.gms.tasks.zzu.getResult(Unknown Source:15)
        at com.myApp.MainActivity$2.onComplete(MainActivity.java:349)
        at com.google.android.gms.tasks.zzj.run(Unknown Source:4)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:7804)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1068)
     Caused by: java.io.IOException: FIS_AUTH_ERROR
        at com.google.firebase.iid.zzs.zza(com.google.firebase:firebase-iid@@20.1.0:82)
        at com.google.firebase.iid.zzs.zza(com.google.firebase:firebase-iid@@20.1.0:96)
        at com.google.firebase.iid.zzx.then(com.google.firebase:firebase-iid@@20.1.0:4)
        at com.google.android.gms.tasks.zzd.run(Unknown Source:5)
        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)

Here is the part of the code where crash occurs:

        FirebaseInstanceId.getInstance().getInstanceId().addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
            @Override
            public void onComplete(@NonNull Task<InstanceIdResult> task) {
                if (task.getResult() != null && task.isSuccessful()) {
                    // Get new Instance ID token
                    firebaseToken = task.getResult().getToken();
                    prefs.edit().putString("firebaseToken", firebaseToken).apply();
                    registerToken();
                }
            }
        });

The error occurs in onComplete. Here is firebase dependencies which I use:

    // FIREBASE
implementation 'com.google.firebase:firebase-analytics:17.2.3'
implementation 'com.google.firebase:firebase-messaging:20.1.2'
implementation 'com.google.firebase:firebase-appindexing:19.1.0'
implementation 'com.google.firebase:firebase-ads:19.0.0'
implementation 'com.google.firebase:firebase-crashlytics:17.0.0-beta01'

I found this issue on Github related with my crash but there is no conclusive solution at all. Does anybody encountered this kind of issue? Thanks in advance.

Note: I don't use Flutter however the error occurs without flutter too. Device is Samsung A51 with Android 10.

Note 2: Firebase removed firebase-core. Problem can be related with that.enter image description here


Solution

  • Temporary but working solution. Just downgrade com.google.firebase:firebase-messaging:20.1.2 to com.google.firebase:firebase-messaging:20.1.0. Apperantly, there is some kind of bug in 20.1.1 and 20.1.2 versions. App doesn't crash anymore.

    UPDATE (11.04.2020): I tested in com.google.firebase:firebase-messaging:20.1.5 and apperantly problem has been fixed.


    UPDATE (26.04.2020):

    I found a permanent solution. First upgrade firebase dependencies to com.google.firebase:firebase-messaging:20.1.6. After that download google-services.json from firebase. Replace it with the current one. After that build > clean project otherwise you can get

    API key expired. Please renew the API key
    

    error. There is no problem with the key, it's some kind of bug of Google. If you completed these steps, add following code into onCreate of your top Application class which is you declared in manifest at the application tag.

    FirebaseOptions options = new FirebaseOptions.Builder()
            .setApplicationId("APP ID") // Required for Analytics.
            .setProjectId("PROJECT ID") // Required for Firebase Installations.
            .setApiKey("GOOGLE API KEY") // Required for Auth.
            .build();
    FirebaseApp.initializeApp(this, options, "FIREBASE APP NAME");
    

    You can found your app id in the firebase > project settings. Also if you're debugging, don't forget to add the debug SHA-256 key to firebase.

    Now I don't get crash anymore. Firebase services work perfectly.