我从源中得到了一个空错误,以显示我的关注和关注列表。 以前它可以工作,但是由于某种原因突然发生了错误。 我不知道为什么要找几天。 帮帮我..
我已经检查了我的Firebase数据列表,但我不知道这不是Firebase问题
这是我的错误
2019-06-18 21:19:51.482 1875-1894/? E/memtrack: Couldn't load memtrack module
2019-06-18 21:19:54.043 14937-14937/com.example.blogapp E/result db user: 2okCgbdTqlVgK6oDqPiYPwyM0kD3
2019-06-18 21:19:54.044 14937-14937/com.example.blogapp E/result db user: 2zUL5Bv7CcPnBENXuWZrr1bxbgs1
2019-06-18 21:19:54.044 14937-14937/com.example.blogapp E/result db user: 6YZdQrf5RycKO1kwvze0vCXL8V83
2019-06-18 21:19:54.045 14937-14937/com.example.blogapp E/id: 6YZdQrf5RycKO1kwvze0vCXL8V83
2019-06-18 21:19:54.045 14937-14937/com.example.blogapp E/arrayList: 7
2019-06-18 21:19:54.045 14937-14937/com.example.blogapp E/result db user: 8wYJrIJ1brPTFvY1GdH2cxv9W4v1
2019-06-18 21:19:54.045 14937-14937/com.example.blogapp E/result db user: BCka8CPfqhfyWZlhgVAwJXDA8fi1
2019-06-18 21:19:54.045 14937-14937/com.example.blogapp E/id: BCka8CPfqhfyWZlhgVAwJXDA8fi1
2019-06-18 21:19:54.045 14937-14937/com.example.blogapp E/arrayList: 7
2019-06-18 21:19:54.046 14937-14937/com.example.blogapp E/result db user: BcNxFCVZZrgxC0pp48G5LQqEP2B2
2019-06-18 21:19:54.046 14937-14937/com.example.blogapp E/result db user: Bj6OGUpKgTYq4JQ2ZtlmTNmb6xj2
2019-06-18 21:19:54.046 14937-14937/com.example.blogapp E/result db user: DAiGCMPqcyOdjIAU7RvHWC0xfbG2
2019-06-18 21:19:54.046 14937-14937/com.example.blogapp E/id: DAiGCMPqcyOdjIAU7RvHWC0xfbG2
2019-06-18 21:19:54.046 14937-14937/com.example.blogapp E/arrayList: 7
2019-06-18 21:19:54.046 14937-14937/com.example.blogapp E/result db user: J9H2hS8jBbcuDhDBdI9ENkCy3Qp1
2019-06-18 21:19:54.047 14937-14937/com.example.blogapp E/result db user: Lo4XZ1pMXGac6BXHEBc7gWz1Lbf2
2019-06-18 21:19:54.047 14937-14937/com.example.blogapp E/result db user: Meqo3PIqWrVv66kmGtVDWXknHbh1
2019-06-18 21:19:54.047 14937-14937/com.example.blogapp E/result db user: NTq9UMZTBefE5Ze2lZdc9hGGhtZ2
2019-06-18 21:19:54.047 14937-14937/com.example.blogapp E/id: NTq9UMZTBefE5Ze2lZdc9hGGhtZ2
2019-06-18 21:19:54.047 14937-14937/com.example.blogapp E/arrayList: 7
2019-06-18 21:19:54.050 14937-14937/com.example.blogapp E/result db user: NmrCWzy7aTXSTMSCnwGRGcm417u1
2019-06-18 21:19:54.050 14937-14937/com.example.blogapp E/result db user: P8uBLb9Ge5MPRbcgrOkl1xJMymI3
2019-06-18 21:19:54.050 14937-14937/com.example.blogapp E/result db user: Sjzjl1pD2PQBoCcc1x0Ji4gaFkI3
2019-06-18 21:19:54.050 14937-14937/com.example.blogapp E/id: Sjzjl1pD2PQBoCcc1x0Ji4gaFkI3
2019-06-18 21:19:54.050 14937-14937/com.example.blogapp E/arrayList: 7
2019-06-18 21:19:54.051 14937-14937/com.example.blogapp E/result db user: VxLgeLvRV9RZO8yg5MfYM2CrsfJ3
2019-06-18 21:19:54.051 14937-14937/com.example.blogapp E/result db user: bazmIYkmqwSdrkNbX6SIFlXuzO22
2019-06-18 21:19:54.051 14937-14937/com.example.blogapp E/result db user: dJCOwYuLAgfEEfhKyxT0bon8zfv2
2019-06-18 21:19:54.051 14937-14937/com.example.blogapp E/result db user: fm6XldWYbOdVQYOuiTVLTRouN573
2019-06-18 21:19:54.052 14937-14937/com.example.blogapp E/id: fm6XldWYbOdVQYOuiTVLTRouN573
2019-06-18 21:19:54.052 14937-14937/com.example.blogapp E/arrayList: 7
2019-06-18 21:19:54.052 14937-14937/com.example.blogapp E/result db user: lPKdx41KR2R3PsZh62ZM3QuyuS93
2019-06-18 21:19:54.052 14937-14937/com.example.blogapp E/result db user: m8sTZfxm3xSCysNTLdNYOabXRU23
2019-06-18 21:19:54.052 14937-14937/com.example.blogapp E/result db user: oT1sKEE9ILZjNn2B5O4Yf7gjNqV2
2019-06-18 21:19:54.057 14937-14937/com.example.blogapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.blogapp, PID: 14937
java.lang.NullPointerException: println needs a message
at android.util.Log.println_native(Native Method)
at android.util.Log.e(Log.java:240)
at com.example.together.Activities.FollowersActivity$5.onDataChange(FollowersActivity.java:158)
at com.google.firebase.database.Query$1.onDataChange(com.google.firebase:firebase-database@@17.0.0:184)
at com.google.firebase.database.core.ValueEventRegistration.fireEvent(com.google.firebase:firebase-database@@17.0.0:75)
at com.google.firebase.database.core.view.DataEvent.fire(com.google.firebase:firebase-database@@17.0.0:63)
at com.google.firebase.database.core.view.EventRaiser$1.run(com.google.firebase:firebase-database@@17.0.0:55)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
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)
这是我的完整代码,显示关注者和关注者列表
private void getFollowing(){
DatabaseReference reference = FirebaseDatabase.getInstance().getReference("Follow")
.child(id).child("following");
reference.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
idList.clear();
for (DataSnapshot snapshot : dataSnapshot.getChildren()){
idList.add(snapshot.getKey());
}
showUsers();
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
private void getFollowers(){
DatabaseReference reference = FirebaseDatabase.getInstance().getReference("Follow")
.child(id).child("followers");
reference.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
idList.clear();
for (DataSnapshot snapshot : dataSnapshot.getChildren()){
idList.add(snapshot.getKey());
}
showUsers();
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
private void showUsers(){
DatabaseReference reference = FirebaseDatabase.getInstance().getReference("Users");
reference.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
userList.clear();
for (DataSnapshot snapshot : dataSnapshot.getChildren()){
User user = snapshot.getValue(User.class);
System.out.println(user+"TEST");
Log.e("result db user",user.getId());
for (String id : idList){
if (user.getId().equals(id)){
Log.e("id",user.getId());
Log.e("arrayList",idList.size()+"");
userList.add(user);
}
}
}
userAdapter.notifyDataSetChanged();
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
这是我要查看我的关注者和关注者列表的按钮
followers.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getContext(), FollowersActivity.class);
intent.putExtra("id", profileid);
intent.putExtra("title","followers");
startActivity(intent);
}
});
following.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getContext(), FollowersActivity.class);
intent.putExtra("id", profileid);
intent.putExtra("title","following");
startActivity(intent);
}
});
我想知道什么使它为空。...
答案 0 :(得分:0)
始终记录如下代码(附空白字符串字符)之类的错误,
Log.e("id",user.getId()+"");
不是这样,
Log.e("id",user.getId());