I am trying to access the ‘Device Explorer’ tab in Android Studio for virtual device "Pixel 2 API 19". Unfortunately, it shows a red message saying Unable to access root directory of device: sh: stat: not found
which does not tell me anything.
I have tried the following, but none has worked:
- restarting the emulator;
- restarting the device;
- wiping data from the device;
- closing the project and opening it again;
- restarting my PC.
The problem seems to have appeared in the new version of Android Studio because it never used to be there before the update. My current version is Android Studio Hedgehog | 2023.1.1 Patch 1
, my OS is Linux Mint XFCE
.
I have also got virtual devices "Galaxy Nexus API 26" and "Pixel 2 API 23", but the error does not show for either of them.
2
Answers
Have you tried running Android Studio as administrator? Some people have reported it fixing similar issues like this
I encountered the same issue on my custom Oreo(27) build. Running android studio as admin did not work since the ‘Unknown command stat’ error was coming from device not the PC. And adb was already running as root.
But curiously enough, I did not see the issue on an Oreo emulator. This lead me to believe the toybox in my custom build was missing stat for some reason.
Android Studio uses ‘stat’ command to display the device contents under ‘Device Explorer’.
On older android studio release (chipmunk), as per ddmlib logs, the request was rejected by adb (hence, why i didn’t see the issue earlier).
For my custom Oreo device, I could see that this request fails due to ‘Unknown command stat’
Someone had accidentally removed stat from the toybox rules 6 years ago! I fixed it by regenerating toybox tools for my build.
Not sure why this would be observed on an emulator. But I would say the android studio logs would be a good place to start.