java Firebase firestore提供空指针异常
我试图从我的firebase firestore获取数据,我觉得一切正常,但我的文本视图变得空白。我也没有在与概要活动和类相关的日志中得到任何错误。我在我的另一个应用程序中也以同样的方式使用了firestore,它在那里工作得非常好enter image description here 如果你们能在我因为这个错误而停滞不前的时候帮助我,那就太棒了
我的logcat
2020-05-29 14:53:38.381 4280-4280/? E/Zygote: v2
2020-05-29 14:53:38.385 4280-4280/? E/Zygote: accessInfo : 0
2020-05-29 14:53:43.495 4280-4280/com.example.feedme E/BoostFramework: BoostFramework() : Exception_1 = java.lang.ClassNotFoundException: Didn't find class "com.qualcomm.qti.Performance" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib64, /vendor/lib64]]
我的java代码:
import 安卓.content.Intent;
import 安卓.os.Bundle;
import 安卓.util.Log;
import 安卓.widget.TextView;
import 安卓.widget.Toast;
import 安卓x.annotation.Nullable;
import 安卓x.appcompat.app.AppCompatActivity;
import com.google.安卓.material.bottomnavigation.BottomNavigationView;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.firestore.DocumentReference;
import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.EventListener;
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.firestore.FirebaseFirestoreException;
import com.squareup.picasso.Picasso;
import de.hdodenhof.circleimageview.CircleImageView;
public class profile extends AppCompatActivity {
TextView namea;
CircleImageView circleImageView;
BottomNavigationView bottomNavigationView;
String user_id;
String url;
FirebaseFirestore fStore;
FirebaseAuth fAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_profile);
Toast.makeText(this, user_id, Toast.LENGTH_SHORT).show();
circleImageView = findViewById(R.id.profilepictureuser);
Picasso.with(this).load(url).resize(400, 400).centerCrop().into(circleImageView);
namea = findViewById(R.id.profilename);
fStore = FirebaseFirestore.getInstance();
fAuth = FirebaseAuth.getInstance();
user_id = fAuth.getCurrentUser().getUid();
DocumentReference documentReference = fStore.collection("User data").document(user_id);
documentReference.addSnapshotListener(this, new EventListener<DocumentSnapshot>() {
@Override
public void onEvent(@Nullable DocumentSnapshot documentSnapshot, @Nullable FirebaseFirestoreException e) {
namea.setText(documentSnapshot.getString("Full name"));
}
});
bottomNavigationView = findViewById(R.id.bottom_navigation1);
bottomNavigationView.setSelectedItemId(R.id.profilelogo);
bottomNavigationView.setOnNavigationItemSelectedListener(item -> {
switch (item.getItemId()) {
case R.id.profilelogo:
return true;
case R.id.home:
startActivity(new Intent(getApplicationContext(), homepage.class));
return true;
}
return false;
});
}
}
[enter image description here][1]
配置文件的布局文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:app="http://schemas.安卓.com/apk/res-auto"
xmlns:tools="http://schemas.安卓.com/tools"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
tools:context=".profile">
<LinearLayout
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:id="@+id/linearlayout"
安卓:orientation="vertical">
<de.hdodenhof.circleimageview.CircleImageView
安卓:layout_width="80dp"
安卓:layout_height="80dp"
安卓:src="@drawable/profile"
安卓:id="@+id/profilepictureuser"
安卓:layout_gravity="center"
安卓:layout_marginTop="30dp"/>
<TextView
安卓:id="@+id/profilename"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_gravity="center"
安卓:layout_marginTop="15dp"
安卓:textColor="#000000"
安卓:textSize="24sp" />
</LinearLayout>
<com.google.安卓.material.bottomnavigation.BottomNavigationView
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:id="@+id/bottom_navigation1"
安卓:background="#047cfb"
app:itemIconTint="#ffffff"
app:itemTextColor="#ffffff"
app:menu="@menu/menu_navigation"
安卓:layout_alignParentBottom="true"
/>
</RelativeLayout>
我的firestore系列:
我添加了一个祝酒词来检查用户id。这是screeshot,代码已经更新了
共 (0) 个答案