FirebaseUIリサイクラービューで異常なエラーが発生します。エラーの添付ファイルも含まれています。これはFirebaseRecyclerビューです。 Firebaseリサイクラーアダプターを使用しています。ユーザーアクティビティに移動するたびにクラッシュし、logcatで異常なエラーが発生します。助けてください。これは私のコードです:
private Toolbar mToolbar;
private RecyclerView mUsersList;
private DatabaseReference AllUsersRef;
private FirebaseAuth mAuth;
String currentUserID;
private Query query;
private FirebaseRecyclerOptions<Users> options;
private FirebaseRecyclerAdapter<Users, UsersViewHolder> adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_users);
AllUsersRef = FirebaseDatabase.getInstance().getReference().child("users");
mToolbar = findViewById(R.id.users_app_bar);
setSupportActionBar(mToolbar);
getSupportActionBar().setTitle("All Users");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mUsersList = findViewById(R.id.users_list);
mUsersList.setHasFixedSize(true);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
mUsersList.setLayoutManager(linearLayoutManager);
}
@Override
protected void onStart() {
super.onStart();
AllUsersRef.child("online").setValue(true);
options = new FirebaseRecyclerOptions.Builder<Users>().setQuery(AllUsersRef, Users.class).build();
adapter = new FirebaseRecyclerAdapter<Users, UsersViewHolder>(options) {
@Override
protected void onBindViewHolder(@NonNull UsersViewHolder holder, int position, @NonNull Users model) {
final String user_id = getRef(position).getKey();
holder.mName.setText(model.getName());
holder.mStatus.setText(model.getStatus());
Picasso.get().load(model.getImage()).into(holder.mImage);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent profileIntent = new Intent(UsersActivity.this, ProfileActivity.class);
profileIntent.putExtra("user_id", user_id);
startActivity(profileIntent);
}
});
}
@NonNull
@Override
public UsersViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.users_display_layout, viewGroup, false);
return new UsersViewHolder(view);
}
};
adapter.startListening();
mUsersList.setAdapter(adapter);
}
@Override
protected void onStop() {
super.onStop();
FirebaseUser currentUser = FirebaseAuth.getInstance().getCurrentUser();
if(currentUser != null) {
//AllUsersRef.child("online").setValue(false);
}
}
}
これは私のLOgCatエラーです:
08-30 18:16:01.581 2667-9189/com.google.Android.googlequicksearchbox:search E/EntrySyncManager: Cannot determine account name: drop request
08-30 18:16:01.582 2667-9189/com.google.Android.googlequicksearchbox:search E/NowController: Failed to access data from EntryProvider. ExecutionException.
Java.util.concurrent.ExecutionException: com.google.Android.apps.gsa.sidekick.main.h.n: Could not complete scheduled request to refresh entries. ClientErrorCode: 3
at com.google.common.util.concurrent.d.eA(SourceFile:85)
at com.google.common.util.concurrent.d.get(SourceFile:23)
at com.google.common.util.concurrent.l.get(SourceFile:2)
at com.google.Android.apps.gsa.staticplugins.nowstream.b.a.be.caI(SourceFile:47)
at com.google.Android.apps.gsa.staticplugins.nowstream.b.a.be.caH(SourceFile:176)
at com.google.Android.apps.gsa.staticplugins.nowstream.b.a.bh.run(Unknown Source:2)
at com.google.Android.apps.gsa.shared.util.concurrent.at.run(SourceFile:4)
at Java.util.concurrent.Executors$RunnableAdapter.call(Executors.Java:458)
at Java.util.concurrent.FutureTask.run(FutureTask.Java:266)
at Java.util.concurrent.Executors$RunnableAdapter.call(Executors.Java:458)
at Java.util.concurrent.FutureTask.run(FutureTask.Java:266)
at com.google.Android.apps.gsa.shared.util.concurrent.b.g.run(Unknown Source:4)
at com.google.Android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4)
at com.google.Android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4)
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:764)
at com.google.Android.apps.gsa.shared.util.concurrent.b.i.run(SourceFile:6)
Caused by: com.google.Android.apps.gsa.sidekick.main.h.n: Could not complete scheduled request to refresh entries. ClientErrorCode: 3
at com.google.Android.apps.gsa.staticplugins.nowstream.b.a.aq.az(Unknown Source:4)
at com.google.common.util.concurrent.q.ap(SourceFile:7)
at com.google.common.util.concurrent.p.run(SourceFile:32)
at com.google.common.util.concurrent.bt.execute(SourceFile:3)
at com.google.common.util.concurrent.d.b(SourceFile:275)
at com.google.common.util.concurrent.d.addListener(SourceFile:135)
at com.google.common.util.concurrent.p.b(SourceFile:3)
at com.google.Android.apps.gsa.shared.util.concurrent.h.a(SourceFile:16)
at com.google.Android.apps.gsa.shared.util.concurrent.h.a(SourceFile:13)
at com.google.Android.apps.gsa.staticplugins.nowstream.b.a.be.caI(SourceFile:45)
at com.google.Android.apps.gsa.staticplugins.nowstream.b.a.be.caH(SourceFile:176)
at com.google.Android.apps.gsa.staticplugins.nowstream.b.a.bh.run(Unknown Source:2)
at com.google.Android.apps.gsa.shared.util.concurrent.at.run(SourceFile:4)
at Java.util.concurrent.Executors$RunnableAdapter.call(Executors.Java:458)
at Java.util.concurrent.FutureTask.run(FutureTask.Java:266)
at Java.util.concurrent.Executors$RunnableAdapter.call(Executors.Java:458)
at Java.util.concurrent.FutureTask.run(FutureTask.Java:266)
at com.google.Android.apps.gsa.shared.util.concurrent.b.g.run(Unknown Source:4)
at com.google.Android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4)
at com.google.Android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4)
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:764)
at com.google.Android.apps.gsa.shared.util.concurrent.b.i.run(SourceFile:6)
同じ問題が発生しましたが、実際の問題はLogCatのこのエラーの数行上にあることに気付きました。ホルダーのボタンのテキストをintとして設定していたことが判明しました。これが問題の原因でした。これは、問題を修正した従来のString.valueOf()
を使用する必要があるためです。
問題はFirebaseに関連していないようです。たまたま、holder.mStatus.setText(model.getStatus());
メソッドがintを返している場合は、問題はgetStatus()
行にある可能性があります。私の場合と同じように、String.valueOf()
で囲んでみてください。
これがお役に立てば幸いです。