每当我点击这个片段时,我的应用程序就会崩溃

my app crashes whenever i click on this fragment

activity fragment_gallery 一开始显示得很好,但在我在 firebase 的 RecycleView 中添加了一些图片后,即使我删除了这些图片(数据),我的应用程序也开始崩溃,尽管我的应用程序的其余部分工作得很好,但只有这个 activity(片段)导致了问题

GalleryFragment.java

package com.example.universityapp.ui.gallery;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.universityapp.R;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;

import java.util.ArrayList;
import java.util.List;

public class GalleryFragment extends Fragment {


    RecyclerView convoRecycler, otherRecycler;
    GalleryAdapter adapter;

    DatabaseReference reference;


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_gallery, container, false);

        convoRecycler = view.findViewById(R.id.convoRecycler);
        otherRecycler = view.findViewById(R.id.otherRecycler);

        reference = FirebaseDatabase.getInstance().getReference().child("gallery");

        getConvoImage();


        getOtherImage();


        return view;
    }

    private void getOtherImage() {
        reference.child("Other Events").addValueEventListener(new ValueEventListener() {

            List<String> imageList = new ArrayList<>();

            @Override
            public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                for (DataSnapshot snapshot: dataSnapshot.getChildren()) {
                    String data = (String) snapshot.getValue();
                    imageList.add(data);
                }

                adapter = new GalleryAdapter(getContext(), imageList);
                otherRecycler.setLayoutManager(new GridLayoutManager(getContext(), 3));
                otherRecycler.setAdapter(adapter);
            }

            @Override
            public void onCancelled(@NonNull DatabaseError error) {

            }
        });
    }

    private void getConvoImage() {
        reference.child("Convocation").addValueEventListener(new ValueEventListener() {

            List<String> imageList = new ArrayList<>();

            @Override
            public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                for (DataSnapshot snapshot: dataSnapshot.getChildren()) {
                    String data = (String) snapshot.getValue();
                    imageList.add(data);
                }

                adapter = new GalleryAdapter(getContext(), imageList);
                convoRecycler.setLayoutManager(new GridLayoutManager(getContext(), 3));
                convoRecycler.setAdapter(adapter);
            }

            @Override
            public void onCancelled(@NonNull DatabaseError error) {

            }
        });
    }
}

这是导致崩溃的 activity:fragment_gallery.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    tools:context=".ui.gallery.GalleryFragment">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="@dimen/text_margin"
        android:orientation="vertical">

        <com.google.android.material.card.MaterialCardView
            android:layout_width="match_parent"
            android:layout_marginVertical="8dp"
            android:layout_height="280dp">


            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Convocation"
                    android:layout_marginTop="@dimen/text_margin"
                    android:textSize="@dimen/title_size"
                    android:layout_gravity="center_horizontal"
                    android:textColor="@color/textColor"
                    android:fontFamily="@string/bold"/>

                <View
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:layout_marginVertical="4dp"
                    android:background="@color/grey"/>

                <androidx.recyclerview.widget.RecyclerView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/convoRecycler"/>



            </LinearLayout>





        </com.google.android.material.card.MaterialCardView>

        <com.google.android.material.card.MaterialCardView
            android:layout_width="match_parent"
            android:layout_marginVertical="8dp"
            android:layout_height="280dp">


            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Others"
                    android:layout_marginTop="@dimen/text_margin"
                    android:textSize="@dimen/title_size"
                    android:layout_gravity="center_horizontal"
                    android:textColor="@color/textColor"
                    android:fontFamily="@string/bold"/>

                <View
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:layout_marginVertical="4dp"
                    android:background="@color/grey"/>

                <androidx.recyclerview.widget.RecyclerView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/otherRecycler"/>



            </LinearLayout>





        </com.google.android.material.card.MaterialCardView>

    </LinearLayout>

</androidx.core.widget.NestedScrollView>

这里是 Logcat 当我的应用程序崩溃时:

2022-04-20 16:35:17.834 20082-20082/? I/e.universityap: Late-enabling -Xcheck:jni
2022-04-20 16:35:17.856 20082-20082/? I/e.universityap: Unquickening 22 vdex files!
2022-04-20 16:35:17.857 20082-20082/? E/e.universityap: Unknown bits set in runtime_flags: 0x800000
2022-04-20 16:35:17.920 20082-20082/? I/ForceDarkHelper: mForceDarkOrigin true
2022-04-20 16:35:17.922 20082-20082/? I/MiuiForceDarkConfig: MiuiForceDarkConfig setConfig density:2.750000, mainRule:0, secondaryRule:0, tertiaryRule:0
2022-04-20 16:35:17.924 20082-20082/? D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2022-04-20 16:35:17.925 20082-20082/? D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2022-04-20 16:35:17.933 20082-20107/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:17.934 20082-20107/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:17.941 20082-20107/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:17.943 20082-20107/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:17.944 20082-20082/? I/FirebaseApp: Device unlocked: initializing all Firebase APIs for app [DEFAULT]
2022-04-20 16:35:17.944 20082-20107/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:17.945 20082-20107/? E/ion: ioctl c0044901 failed with code -1: Invalid argument
2022-04-20 16:35:17.945 20082-20107/? D/skia: SkJpegCodec::onGetPixels +
2022-04-20 16:35:17.946 20082-20107/? D/skia: stream getLength() supported, buffer addr 0x72f647a000 length 186496
2022-04-20 16:35:17.946 20082-20107/? D/skia: size 186286,phy_addr 0x43300000
2022-04-20 16:35:17.946 20082-20107/? D/skia: LoadInputStreamToIonMem va 0x72f647a000 pa 0x43300000
2022-04-20 16:35:17.947 20082-20107/? D/libjpeg-alpha-oal: SWIP_INIT
2022-04-20 16:35:17.947 20082-20107/? D/libjpeg-alpha-oal: MTXXXX_JPEG_SWIP_PROTECTION value=1
2022-04-20 16:35:17.947 20082-20107/? D/libjpeg-alpha-oal: Address(orig)     = 0x73813dd258 0xedc
2022-04-20 16:35:17.947 20082-20107/? D/libjpeg-alpha-oal: Address(modified) = 0x73813dc37c
2022-04-20 16:35:17.947 20082-20107/? D/libjpeg-alpha-oal: Intermidiate 73813d8088, aff3
2022-04-20 16:35:17.948 20082-20107/? D/libjpeg-alpha-oal: SWIP_INIT return
2022-04-20 16:35:17.948 20082-20107/? D/libjpeg-alpha: Huffman Builder run in subthread
2022-04-20 16:35:17.948 20082-20107/? D/libjpeg-alpha: Tile Decoder (#thread:4, size:512 256 256 416x208, alignment:256x16)
2022-04-20 16:35:17.942 20082-20082/? W/com.example.universityapp: type=1400 audit(0.0:761825): avc: denied { search } for comm=4173796E635461736B202331 name="ppm" dev="proc" ino=4026531936 scontext=u:r:untrusted_app:s0:c43,c257,c512,c768 tcontext=u:object_r:proc_ppm:s0 tclass=dir permissive=0 app=com.example.universityapp
2022-04-20 16:35:17.946 20082-20082/? W/com.example.universityapp: type=1400 audit(0.0:761826): avc: denied { search } for comm=4173796E635461736B202331 name="ppm" dev="proc" ino=4026531936 scontext=u:r:untrusted_app:s0:c43,c257,c512,c768 tcontext=u:object_r:proc_ppm:s0 tclass=dir permissive=0 app=com.example.universityapp
2022-04-20 16:35:17.949 20082-20110/? D/libjpeg-alpha: Inconsistent progression sequence for component 0 coefficient 0
2022-04-20 16:35:17.949 20082-20112/? D/libjpeg-alpha: Inconsistent progression sequence for component 0 coefficient 0
2022-04-20 16:35:17.949 20082-20111/? D/libjpeg-alpha: Inconsistent progression sequence for component 0 coefficient 0
2022-04-20 16:35:17.950 20082-20113/? D/libjpeg-alpha: Inconsistent progression sequence for component 0 coefficient 0
2022-04-20 16:35:17.950 20082-20109/? D/libjpeg-alpha: Corrupt JPEG data: 16743 extraneous bytes before marker 0xc4
2022-04-20 16:35:17.950 20082-20114/? W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
2022-04-20 16:35:17.954 20082-20113/? D/libjpeg-alpha: Inconsistent progression sequence for component 0 coefficient 0
2022-04-20 16:35:17.955 20082-20110/? D/libjpeg-alpha: Inconsistent progression sequence for component 0 coefficient 0
2022-04-20 16:35:17.955 20082-20112/? D/libjpeg-alpha: Inconsistent progression sequence for component 0 coefficient 0
2022-04-20 16:35:17.955 20082-20111/? D/libjpeg-alpha: Inconsistent progression sequence for component 0 coefficient 0
2022-04-20 16:35:17.959 20082-20110/? D/libjpeg-alpha: Inconsistent progression sequence for component 0 coefficient 0
2022-04-20 16:35:17.959 20082-20113/? D/libjpeg-alpha: Inconsistent progression sequence for component 0 coefficient 0
2022-04-20 16:35:17.960 20082-20112/? D/libjpeg-alpha: Inconsistent progression sequence for component 0 coefficient 0
2022-04-20 16:35:17.962 20082-20111/? D/libjpeg-alpha: Inconsistent progression sequence for component 0 coefficient 0
2022-04-20 16:35:17.965 20082-20111/? D/libjpeg-alpha: Inconsistent progression sequence for component 0 coefficient 0
2022-04-20 16:35:17.965 20082-20112/? D/libjpeg-alpha: Inconsistent progression sequence for component 0 coefficient 0
2022-04-20 16:35:17.966 20082-20110/? D/libjpeg-alpha: Inconsistent progression sequence for component 0 coefficient 0
2022-04-20 16:35:17.966 20082-20113/? D/libjpeg-alpha: Inconsistent progression sequence for component 0 coefficient 0
2022-04-20 16:35:17.968 20082-20116/? W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
2022-04-20 16:35:17.971 20082-20107/? D/skia: SkJpegCodec::onGetPixels -
2022-04-20 16:35:17.971 20082-20082/? I/FirebaseInitProvider: FirebaseApp initialization successful
2022-04-20 16:35:17.972 20082-20107/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:17.973 20082-20116/? W/GooglePlayServicesUtil: com.example.universityapp requires the Google Play Store, but it is missing.
2022-04-20 16:35:17.974 20082-20116/? W/GoogleApiManager: The service for com.google.firebase.auth.api.internal.zzeg is not available: ConnectionResult{statusCode=SERVICE_INVALID, resolution=null, message=null}
2022-04-20 16:35:17.978 20082-20082/? I/ContentProviderMonitor: PerfMonitor installContentProviders : before publish content providers
2022-04-20 16:35:17.980 20082-20107/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:17.982 20082-20107/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:17.989 20082-20119/? I/DynamiteModule: Considering local module com.google.android.gms.measurement.dynamite:17 and remote module com.google.android.gms.measurement.dynamite:67
2022-04-20 16:35:17.989 20082-20119/? I/DynamiteModule: Selected remote version of com.google.android.gms.measurement.dynamite, version >= 67
2022-04-20 16:35:17.990 20082-20119/? V/DynamiteModule: Dynamite loader version >= 2, using loadModule2NoCrashUtils
2022-04-20 16:35:18.027 20082-20082/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:18.045 20082-20082/? D/View: com.example.universityapp initForcedUseForceDark: 1
2022-04-20 16:35:18.058 20082-20082/? D/DecorView[]: getWindowModeFromSystem  windowmode is 1
2022-04-20 16:35:18.065 20082-20119/? V/FA: onActivityCreated
2022-04-20 16:35:18.085 20082-20082/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:18.088 20082-20082/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:18.097 20082-20082/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:18.101 20082-20082/? W/e.universityap: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
2022-04-20 16:35:18.102 20082-20082/? W/e.universityap: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
2022-04-20 16:35:18.116 20082-20126/? V/FA: App measurement collection enabled
2022-04-20 16:35:18.116 20082-20126/? V/FA: App measurement enabled for app package, google app id: com.example.universityapp, 1:264695498772:android:837d69c53db8cfa6897f01
2022-04-20 16:35:18.117 20082-20126/? I/FA: App measurement initialized, version: 58022
2022-04-20 16:35:18.117 20082-20126/? I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
2022-04-20 16:35:18.117 20082-20126/? I/FA: To enable faster debug mode event logging run:
      adb shell setprop debug.firebase.analytics.app com.example.universityapp
2022-04-20 16:35:18.117 20082-20126/? D/FA: Debug-level message logging enabled
2022-04-20 16:35:18.137 20082-20082/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:18.151 20082-20126/? V/FA: Connecting to remote service
2022-04-20 16:35:18.157 20082-20126/? V/FA: Connection attempt already in progress
2022-04-20 16:35:18.160 20082-20126/? V/FA: Connection attempt already in progress
2022-04-20 16:35:18.184 20082-20082/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:18.232 20082-20082/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:18.237 20082-20082/? I/chatty: uid=10299(com.example.universityapp) identical 1 line
2022-04-20 16:35:18.248 20082-20082/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:18.260 20082-20082/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:18.282 20082-20082/? I/chatty: uid=10299(com.example.universityapp) identical 2 lines
2022-04-20 16:35:18.305 20082-20082/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:18.311 20082-20082/? W/ActionBarDrawerToggle: DrawerToggle may not show up because NavigationIcon is not visible. You may need to call actionbar.setDisplayHomeAsUpEnabled(true);
2022-04-20 16:35:18.324 20082-20126/? V/FA: Activity resumed, time: 751123979
2022-04-20 16:35:18.325 20082-20126/? I/FA: Tag Manager is not found and thus will not be used
2022-04-20 16:35:18.328 20082-20082/? I/SurfaceFactory: [static] sSurfaceFactory = com.mediatek.view.impl.SurfaceFactoryImpl@c51360e
2022-04-20 16:35:18.335 20082-20082/? D/ViewRootImpl[MainActivity]: hardware acceleration = true , fakeHwAccelerated = false, sRendererDisabled = false, forceHwAccelerated = false, sSystemRendererDisabled = false
2022-04-20 16:35:18.341 20082-20082/? I/InputTransport: Create ARC handle: 0xb40000728e6dd440
2022-04-20 16:35:18.342 20082-20082/? V/PhoneWindow: DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl@4837228, this = DecorView@baffb41[MainActivity]
2022-04-20 16:35:18.343 20082-20082/? W/Looper: PerfMonitor looperActivity : package=com.example.universityapp/.MainActivity time=0ms latency=452ms running=0ms  procState=2 ClientTransaction{ callbacks=[android.app.servertransaction.TopResumedActivityChangeItem] } historyMsgCount=4 (msgIndex=3 wall=90ms seq=3 running=71ms runnable=4ms io=2ms late=6ms h=android.app.ActivityThread$H w=110) (msgIndex=4 wall=358ms seq=4 running=325ms runnable=2ms late=94ms h=android.app.ActivityThread$H w=159)
2022-04-20 16:35:18.351 20082-20126/? V/FA: Connection attempt already in progress
2022-04-20 16:35:18.352 20082-20126/? V/FA: Connection attempt already in progress
2022-04-20 16:35:18.385 20082-20082/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:18.387 20082-20082/? I/chatty: uid=10299(com.example.universityapp) identical 2 lines
2022-04-20 16:35:18.390 20082-20082/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:18.394 20082-20082/? W/Glide: Failed to find GeneratedAppGlideModule. You should include an annotationProcessor compile dependency on com.github.bumptech.glide:compiler in your application and a @GlideModule annotated AppGlideModule implementation or LibraryGlideModules will be silently ignored
2022-04-20 16:35:18.463 20082-20082/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:18.482 20082-20082/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:18.492 20082-20082/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:18.502 20082-20082/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:18.512 20082-20082/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:18.522 20082-20082/? I/chatty: uid=10299(com.example.universityapp) identical 1 line
2022-04-20 16:35:18.531 20082-20082/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:18.559 20082-20146/? E/libc: Access denied finding property "vendor.debug.drm.logv"
2022-04-20 16:35:18.559 20082-20146/? E/libc: Access denied finding property "vendor.debug.drm.logv"
2022-04-20 16:35:18.559 20082-20146/? E/libc: Access denied finding property "vendor.debug.drm.logd"
2022-04-20 16:35:18.559 20082-20146/? E/libc: Access denied finding property "vendor.debug.drm.logv"
2022-04-20 16:35:18.565 20082-20123/? E/ion: ioctl c0044901 failed with code -1: Invalid argument
2022-04-20 16:35:18.565 20082-20146/? D/skia: SkJpegCodec::onGetPixels +
2022-04-20 16:35:18.565 20082-20146/? D/libjpeg-alpha-oal: SWIP_INIT return
2022-04-20 16:35:18.569 20082-20146/? D/skia: SkJpegCodec::onGetPixels -
2022-04-20 16:35:18.588 20082-20146/? D/skia: SkJpegCodec::onGetPixels +
2022-04-20 16:35:18.588 20082-20146/? D/libjpeg-alpha-oal: SWIP_INIT return
2022-04-20 16:35:18.593 20082-20146/? D/skia: SkJpegCodec::onGetPixels -
2022-04-20 16:35:18.611 20082-20082/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:18.613 20082-20082/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:18.625 20082-20082/? I/TetheringManager: registerTetheringEventCallback:com.example.universityapp
2022-04-20 16:35:18.635 20082-20126/? D/FA: Connected to remote service
2022-04-20 16:35:18.635 20082-20126/? V/FA: Processing queued up service tasks: 5
2022-04-20 16:35:19.739 20082-20146/? D/skia: SkJpegCodec::onGetPixels +
2022-04-20 16:35:19.739 20082-20146/? D/libjpeg-alpha-oal: SWIP_INIT return
2022-04-20 16:35:19.743 20082-20146/? D/skia: SkJpegCodec::onGetPixels -
2022-04-20 16:35:21.716 20082-20082/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:21.718 20082-20082/? I/chatty: uid=10299(com.example.universityapp) identical 1 line
2022-04-20 16:35:21.718 20082-20082/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:21.737 20082-20146/? D/skia: SkJpegCodec::onGetPixels +
2022-04-20 16:35:21.737 20082-20146/? D/libjpeg-alpha-oal: SWIP_INIT return
2022-04-20 16:35:21.753 20082-20146/? D/skia: SkJpegCodec::onGetPixels -
2022-04-20 16:35:23.678 20082-20126/? V/FA: Inactivity, disconnecting from the service
2022-04-20 16:35:23.727 20082-20146/? D/skia: SkJpegCodec::onGetPixels +
2022-04-20 16:35:23.727 20082-20146/? D/libjpeg-alpha-oal: SWIP_INIT return
2022-04-20 16:35:23.731 20082-20146/? D/skia: SkJpegCodec::onGetPixels -
2022-04-20 16:35:29.245 20082-20082/? E/libc: Access denied finding property "ro.vendor.pref_scale_resolution"
2022-04-20 16:35:29.286 20082-20082/? E/RecyclerView: No adapter attached; skipping layout
2022-04-20 16:35:29.286 20082-20082/? E/RecyclerView: No adapter attached; skipping layout
2022-04-20 16:35:29.319 20082-20156/? I/System.out: [socket]:check permission begin!
2022-04-20 16:35:30.449 20082-20082/? I/ViewTarget: Glide treats LayoutParams.WRAP_CONTENT as a request for an image the size of this device's screen dimensions. If you want to load the original image and are ok with the corresponding memory cost and OOMs (depending on the input size), use override(Target.SIZE_ORIGINAL). Otherwise, use LayoutParams.MATCH_PARENT, set layout_width and layout_height to fixed dimension, or use .override() with fixed dimensions.
2022-04-20 16:35:30.459 20082-20082/? D/AndroidRuntime: Shutting down VM
2022-04-20 16:35:30.462 20082-20082/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.universityapp, PID: 20082
    java.lang.ClassCastException: java.util.HashMap cannot be cast to java.lang.String
        at com.example.universityapp.ui.gallery.GalleryFragment.onDataChange(GalleryFragment.java:85)
        at com.google.firebase.database.core.ValueEventRegistration.fireEvent(ValueEventRegistration.java:75)
        at com.google.firebase.database.core.view.DataEvent.fire(DataEvent.java:63)
        at com.google.firebase.database.core.view.EventRaiser.run(EventRaiser.java:55)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:236)
        at android.app.ActivityThread.main(ActivityThread.java:8049)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:620)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1011)
2022-04-20 16:35:30.467 20082-20146/? D/skia: stream getLength() not supported, use temp buffer for loading stream, buffer addr 0x72ea85c000 length 314070
2022-04-20 16:35:30.467 20082-20146/? D/skia: size 314070,phy_addr 0x43300000
2022-04-20 16:35:30.467 20082-20146/? D/skia: LoadInputStreamToIonMem va 0x72ea85c000 pa 0x43300000
2022-04-20 16:35:30.467 20082-20146/? D/libjpeg-alpha-oal: SWIP_INIT return
2022-04-20 16:35:30.468 20082-20146/? D/libjpeg-alpha-oal: SWIP_INIT return
2022-04-20 16:35:30.468 20082-20146/? D/libjpeg-alpha: Huffman Builder run in subthread
2022-04-20 16:35:30.469 20082-20146/? D/libjpeg-alpha: Tile Decoder (#thread:4, size:1024 1024 1024 1008x768, alignment:256x16)
2022-04-20 16:35:30.466 20082-20082/? W/glide-disk-cach: type=1400 audit(0.0:761827): avc: denied { search } for name="ppm" dev="proc" ino=4026531936 scontext=u:r:untrusted_app:s0:c43,c257,c512,c768 tcontext=u:object_r:proc_ppm:s0 tclass=dir permissive=0 app=com.example.universityapp
2022-04-20 16:35:30.466 20082-20082/? W/glide-disk-cach: type=1400 audit(0.0:761828): avc: denied { search } for name="ppm" dev="proc" ino=4026531936 scontext=u:r:untrusted_app:s0:c43,c257,c512,c768 tcontext=u:object_r:proc_ppm:s0 tclass=dir permissive=0 app=com.example.universityapp
2022-04-20 16:35:30.526 20082-20082/? I/Process: Sending signal. PID: 20082 SIG: 9

您的应用程序正在崩溃,因为在第 85 行的 GalleryFragment 中抛出 ClassCastException。根据日志记录,您正试图将 HashMap 转换为 String,你不能这样做,因为它不是 class 的 child。为了防止崩溃,你必须解决这个问题;它似乎与您的 fragment_gallery.xml.

没有任何关系

当您调用 String data = (String) snapshot.getValue(); 时,使用 (String) 意味着您基本上希望将 .getValue() 的 return 视为 String。如果 return 值是从 String 扩展的类型,那么这样做是可以的,但 HashMap 不是。

根据您的目的(问题中不清楚),如果您知道 snapshot 将始终为 imageList 类型,则可以将 imageList =12=]。否则,如果它可能是 StringHashMap,那么您可能需要从 HashMap 中获取相关值作为 String.

问题已解决,我需要做的就是将行从

更改为
 String data = (String) snapshot.getValue();

 String data = (String) snapshot.getValue().toString();

我只需将 toString() 添加到该行的末尾,我的应用程序就不会再崩溃了