cachaito
10/9/2019 - 12:07 PM

Rooting Android device/ emulator

After: https://medium.com/@crysfel/updating-the-hosts-file-on-android-emulator-d61a533a76cf

Only Android images such as:

  • Intel x86 Atom System Image
  • Intel x86 Atom_64 System Image
  • Google APIs Intel x86 Atom System Image
  • Google APIs Intel x86 Atom_64 System Image

can be rooted!

  1. adb root
  2. adb remount
  3. adb pull /system/etc/hosts /your/path/hosts
  4. edit hosts
  5. adb push hosts /system/etc/hosts
  6. adb unroot
  • Sometimes it doesn't want to adb remount with error. Then you need to run AVD image with special option. Emulator is hidden in:
  • ~/Library/Android/sdk/emulator
  1. ./emulator -list-avds
  2. ./emulator -avd Pixel_2_API_28_ROOT_2 -writable-system
  • Sometimes it doesn't want to adb push hosts file during read-only rights:
  1. adb reboot
  2. adb root && adb remount && adb push /your/path/hosts /system/etc/hosts
  • editing hosts:
    127.0.0.1 localhost //default
    put_ip_of_your_computer name_to_be_mapped

  • nice commands:

  1. adb shell mount -o rw,remount /;
  2. adb emu kill // shutdown emu