Здравствуйте, у меня возникла проблема с пустыми значениями при входе в игру. Здесь я оставляю вам код ошибки и методы со строками cra sh. Может быть, я что-то неправильно понимаю, извините за мой английский sh.
Код ошибки:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.venomapps.tictactoeonline, PID: 20007
java.lang.NullPointerException: Provided document path must not be null.
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:906)
at com.google.firebase.firestore.CollectionReference.document(com.google.firebase:firebase-firestore@@21.4.0:103)
at com.venomapps.tictactoeonline.Activities.GameActivity.gameListener(GameActivity.java:136)
at com.venomapps.tictactoeonline.Activities.GameActivity.onStart(GameActivity.java:131)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1391)
at android.app.Activity.performStart(Activity.java:7157)
at android.app.ActivityThread.handleStartActivity(ActivityThread.java:2937)
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:180)
at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:165)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:142)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
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:858)
Строки метода: `
@Override
protected void onStart() {
super.onStart();
gameListener();
}
private void gameListener(){
listenerRegistration = database.collection("games")
.document(gameId)
.addSnapshotListener(new EventListener<DocumentSnapshot>() {
@Override
public void onEvent(@Nullable DocumentSnapshot documentSnapshot, @Nullable FirebaseFirestoreException e) {
if(e != null){
Toast.makeText(GameActivity.this, getString(R.string.try_again_later), Toast.LENGTH_LONG).show();
return;
}
assert documentSnapshot != null;
String source = documentSnapshot.getMetadata().hasPendingWrites() ? "Local" : "Server";
if(documentSnapshot.exists() && source.equals("Server")){
// Parsing documentSnapshot to Game object.
game = documentSnapshot.toObject(Game.class);
if(player1Name.isEmpty() || player2Name.isEmpty()){
getPlayerNames();
}
updateUI();
}
updatePlayersUI();
}
});
}