amper12volt Most likely you have accumulated somewhat in permissions to access the repository (or something so). The gallery is dependent on many non-obvious services in the phone.
So you need to sit and keep permissions in all applications in the phone.
Recently fixed such a situation on Redmi 5
I do not remember exactly what I changed, because I was painted very long.