Root an AVD Device

  1. Create a new virtual device on AVD.


Pick any image that does NOT say Play Store in the target column.

Your virtual devices

You can now close android-studio.

  1. Run the emulator.
$ $ANDROID_HOME/emulator/emulator -list-avds
$ $ANDROID_HOME/emulator/emulator -avd Pixel_4a_API_30


$ $ANDROID_HOME/emulator/emulator @Pixel_4a_API_30

Wait for the device to boot, it should appear in adb devices.

$ $ANDROID_HOME/platform-tools/adb devices
List of devices attached
emulator-5554   device
  1. Restart adbd as root and enjoy !
$ $ANDROID_HOME/platform-tools/adb root
restarting adbd as root
$ $ANDROID_HOME/platform-tools/adb shell
generic_x86_arm:/ # id
uid=0(root) gid=0(root) groups=0(root),1004(input),1007(log),1011(adb),1015(sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats),3009(readproc),3011(uhid) context=u:r:su:s0