Firebase 有时会抛出:NullPointerException
Firebase Sometimes Throws: NullPointerException
最近,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:gradle:3.4.2
com.google.gms:google-服务:3.2.0
com.google.firebase:firebase-messaging:11.8.0
构建工具版本 28.0.3
compileSdkVersion 28
minSdkVersion 14
targetSdkVersion 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 版本可能是崩溃的原因。
勾选这个
最近,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:gradle:3.4.2
com.google.gms:google-服务:3.2.0
com.google.firebase:firebase-messaging:11.8.0
构建工具版本 28.0.3
compileSdkVersion 28
minSdkVersion 14
targetSdkVersion 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 版本可能是崩溃的原因。
勾选这个