Start /w Writable System
Using Emulator Images without Google Play
This does not work with production Android images, i.e. ones with Google Play
Use non-Google Play images for root access & writeable system
Start your emulator from a command prompt as a writable system, using its AVD Name (Pixel3a
in this example, see AVD Name below to find or change yours. Make sure another emulator instance is not running when using this command):
emulator @Pixel3a -writable-system
(Keep this command handy. You will need to use it any time you want to access your emulator as 'writable'. I use an alias in gitbash to start my emulator from a gitbash terminal, everytime.)
This launches the emulator.
When startup is complete, open another command prompt/terminal (this one is stuck running the emulator) and:
adb root
Result should be:
$ adb root
restarting adbd as root
Then:
adb remount
Result:
$ adb remount
remount succeeded
When you:
adb shell
and:
su
You should now have full root/writable access:
$ adb shell
generic_x86_arm:/ # su
generic_x86_arm:/ #
To add a domain to hosts file
$ cd /etc
$ cp hosts hosts.bak1
$ cat hosts
127.0.0.1 localhost
::1 ip6-localhost
$ echo '10.0.2.2 my.newdomain.com' >> hosts
$ cat hosts
127.0.0.1 localhost
::1 ip6-localhost
10.0.2.2 my.newdomain.com
10.0.2.2 is "localhost" for an Android emulator. It will delegate to your Windows/Mac hosts file & DNS services. Any domain you add to your development machine's hosts
file, will work as 10.0.2.2
on your Android Emulator hosts file.
AVD Name
In Android Studio AVD Manager can be launched from menu:
Tools > AVD Manager
If your emulator name has spaces, you can change that by clicking the pencil icon on right hand side.
I named my emulator 'Pixel3a' without spaces for ease of typing.
adb root
, thenadb remount
? – Ecstaticadb shell mount -o rw,remount /system
to mount system as r/w – Rosellaroselle