This worked for me when I had the same problem
Go to settings
Open developer options check USB debugging
In that same screen scroll down to USB configuration and check the media transfer button or picture transfer protocol whatever you are trying to do.
Hope this helps