0

Recently, Android devices sometimes throws that error message and crashes:

java.lang.NullPointerException: 
  at com.happycenter.happycan.android.MyFirebaseInstanceIDService.a (Unknown Source:39)
  at com.google.firebase.iid.FirebaseInstanceIdService.b (Unknown Source:12)
  at com.google.firebase.iid.i.run (Unknown Source:24)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1162)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:636)
  at java.lang.Thread.run (Thread.java:764)[/code]

It is obviously related to Firebase.

I sometimes see this report in PlayStore panel.

My Dependencies:

com.android.tools.build:gradle:3.4.2

com.google.gms:google-services:3.2.0

com.google.firebase:firebase-messaging:11.8.0

buildToolsVersion 28.0.3

compileSdkVersion 28

minSdkVersion 14

targetSdkVersion 28

Source Code:

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.FirebaseInstanceIdService;

public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {

    @Override
    public void onTokenRefresh() {
        String token = FirebaseInstanceId.getInstance().getToken();
        registerToken(token);
    }

    private void registerToken(String token){
        FileHandle file;
        file = Gdx.files.local("data/t.txt");
        file.writeString(token, false);
    }
}

What is the reason behind this problem and how can I solve it?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Happy Man
  • 57
  • 5

1 Answers1

1

FirebaseInstanceIdService is deprecated. and non related firebase versions may be the reasons for the crash.

Check this question

source : firebase docs

majurageerthan
  • 2,169
  • 3
  • 17
  • 30