Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/203.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
调试错误:java.lang.ClassCastException:java.lang.Long无法转换为java.util.List_Java_Android_Firebase_Google Cloud Firestore - Fatal编程技术网

调试错误:java.lang.ClassCastException:java.lang.Long无法转换为java.util.List

调试错误:java.lang.ClassCastException:java.lang.Long无法转换为java.util.List,java,android,firebase,google-cloud-firestore,Java,Android,Firebase,Google Cloud Firestore,每次我在应用程序中单击一个配置文件时,它都会导致崩溃和错误,我想知道原因并尝试找到它 错误: java.lang.ClassCastException:java.lang.Long不能强制转换为java.util.List 在com.example.soulforge.fragments.Profile.lambda$loadbasicata$4$Profile(Profile.java:274) 在com.example.soulforge.fragments.-$$Lambda$Profil

每次我在应用程序中单击一个配置文件时,它都会导致崩溃和错误,我想知道原因并尝试找到它

错误:

java.lang.ClassCastException:java.lang.Long不能强制转换为java.util.List
在com.example.soulforge.fragments.Profile.lambda$loadbasicata$4$Profile(Profile.java:274)
在com.example.soulforge.fragments.-$$Lambda$Profile$KwoPqF2dchhRaWfrPFWRwwexTfQ.onEvent(未知来源:4)
位于com.google.firebase.firestore.DocumentReference.lambda$addSnapshotListenerInternal$2(DocumentReference.java:504)
位于com.google.firebase.firestore.DocumentReference$$Lambda$3.onEvent(未知来源:6)
位于com.google.firebase.firestore.core.AsyncEventListener.lambda$onEvent$0(AsyncEventListener.java:42)
位于com.google.firebase.firestore.core.AsyncEventListener$$Lambda$1.run(未知来源:6)
位于android.os.Handler.handleCallback(Handler.java:938)
位于android.os.Handler.dispatchMessage(Handler.java:99)
位于android.os.Looper.loop(Looper.java:223)
位于android.app.ActivityThread.main(ActivityThread.java:7656)
位于java.lang.reflect.Method.invoke(本机方法)
位于com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
位于com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
导致问题的配置文件部分

followersList=(List)value.get(“followers”);
followList=(List)value.get(“following”);
以及整个profile.java

公共类概要文件扩展了片段{
布尔isMyProfile=true;
字符串uid;
字符串userUID;
FirestoreRecyclerAdapter适配器;
私有文本视图名称电视、工具栏名称电视、状态电视、followersCountTv、followersCountTv、postCountTv;
私有CircleImageView配置文件图像;
私人按钮跟随;
私人回收站;
私人线路布局;
私有FirebaseUser用户;
私有ImageButton编辑配置文件BTN;
列表跟随者列表,跟随者列表,跟随者列表2;
其次是布尔型;
文档引用userRef,myRef;
公众简介(){
//必需的空公共构造函数
}
@凌驾
创建视图上的公共视图(布局、充气机、视图组容器、,
Bundle savedInstanceState){
//为该碎片膨胀布局
返回充气机。充气(R.layout.fragment_外形,容器,假);
}
@凌驾
已创建公用void onview(@NonNull视图,@Nullable Bundle savedInstanceState){
super.onViewCreated(视图,savedInstanceState);
初始(视图);
myRef=FirebaseFirestore.getInstance()集合(“用户”)
.document(user.getUid());
如果(是搜索用户){
isMyProfile=false;
userUID=用户ID;
loadData();
}否则{
isMyProfile=true;
userUID=user.getUid();
}
if(isMyProfile){
editProfileBtn.setVisibility(View.VISIBLE);
followBtn.setVisibility(View.GONE);
countLayout.setVisibility(View.VISIBLE);
}否则{
editProfileBtn.setVisibility(View.GONE);
followBtn.setVisibility(View.VISIBLE);
countLayout.setVisibility(View.GONE);
}
userRef=FirebaseFirestore.getInstance().collection(“用户”)
.文件(userUID);
loadBasicATA();
recyclerView.setHasFixedSize(true);
setLayoutManager(新的GridLayoutManager(getContext(),3));
loadpositmages();
recyclerView.setAdapter(适配器);
单击侦听器();
}
私有void loadData(){
myRef.addSnapshotListener(新的EventListener(){
@凌驾
public void onEvent(@Nullable DocumentSnapshot值,@Nullable FirebaseFirestoreException错误){
if(错误!=null){
Log.e(“Tag_b”,error.getMessage());
返回;
}
如果(value==null | |!value.exists()){
返回;
}
followList_2=(List)value.get(“Following”);
}
});
}
私有void clickListener(){
followBtn.setOnClickListener(v->{
如果(后面跟着){
remove(user.getUid());
以下列表2.删除(userUID);
final Map_2=新HashMap();
地图2.放置(“以下”,以下列表2);
Map Map=newhashmap();
地图放置(“跟随者”,跟随者列表);
userRef.update(map).addOnCompleteListener(任务->{
if(task.issusccessful()){
followBtn.setText(“Follow”);
myRef.update(map_2).addOnCompleteListener(task1->{
if(task1.issusccessful()){
Toast.makeText(getContext(),“UnFollowed”,Toast.LENGTH_SHORT.show();
}否则{
Log.e(“Tag_3”,task1.getException().getMessage());
}
});
}否则{
Log.e(“标记”,“任务+task.getException().getMessage());
}
});
}否则{
add(user.getUid());
以下列表2.添加(userUID);
Map Map_2=新的HashMap();
地图2.放置(“以下”,以下列表2);
Map Map=newhashmap();
地图放置(“跟随者”,跟随者列表);
userRef.update(map.addOnCompleteListener(新的OnCompleteListener(){
@凌驾
未完成的公共void(@NonNull任务){
Map<String, Object> followerMap= new HashMap<>();
followerMap= value.getData();
assert followerMap!= null;

for (Map.Entry<String, Object> e : followerMap.entrySet()) {
    long following= e.getValue();
    
    followingList_2 .add(following);
}