I develop an app that communicates to an external database. I have recently started working from home. For development purposes, both the database and Android Studio are on the same workstation, but the access has to be done via URL, so when the app goes into production the only change is the address being accessed.
Back in the office, my company had a DNS to resolve local addresses for us, so my experience with Android Virtual Devices (AVDs) was seamless. But now that I'm at home I need to set the /etc/hosts
file on the virtual machine (and the machine in question uses Googles API, not Google Play, otherwise this would never work).
Following the steps on this awesome thread allowed me to set this up with no problem via command line using the steps below (Linux system):
start emulator on
tools
folder with writable permissios
- tools/emulator -avd <avdname> -writable-system
use
adb
to remount the file system and push a preparedhosts
file into place
- platform-tools/adb root
- platform-tools/adb remount
- platform-tools/adb push <local>/hosts /etc/hosts
This gets the hosts
file where it needs to be, and through Android Studio I can confirm that the file has been edited through File Explorer, and from this point on, development is seamless again.
However, when I close and restart the same virtual machine, now using Android Studio's Device Mananger Play button, the hosts
file resets to what it was previously on the AVD. Also, the file system is no longer writable. As a result, I always have to start the AVD via command line.
I wonder if there's a solution to either:
- save the new
hosts
file permanently on that particular machine so when Android Studio starts it his way the configuration is already there; or - set the
-writable-system
flag to Android Studio's own play button command somehow, so the changes I made in thehosts
file appear again.
I appreciate in advance any thoughts.