最近,Android设备有时会抛出错误消息并崩溃:
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]
它显然与Firebase有关。
我有时会在PlayStore面板中看到此报告。
我的依赖:
com.android.tools.build: g radle:3.4.2
com.google. gm s:google-services:3.2.0
com.google.火力基地:火力基地-信息: 11.8.0
buildToolsVersion 28.0.3
compileSdkVersion 28
minSdkVersion 14
TaretSdkVersion 28
源代码:
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);
}
}
这个问题背后的原因是什么,我该如何解决?
FirebaseInstanceIdService已弃用。和不相关的Firebase版本可能是崩溃的原因。
检查这个问题
来源:Firebase文档