问题
During development I always have to change the hosts file on emulator using following commands in order to map the 10.0.2.2 ip address to dns name. This always worked on Android ADT. But recently I switched to Android Studio and it has stopped working on x86 images. It works for ARM images but those are really slow.
I am doing development on ... Android Studio 2.1.2 Android Platform-tools 24 Android SDK Tools 25.1.7
I use following commands from terminal window in order to do it
adb remount
adb shell
echo '10.0.2.2 xxxx' >>/etc/hosts
I get Read-only File system errors.
UPDATE: Looks like this is a bug in Android tools 25.1.7. I downgraded my tools to 24.1.1 and it is all working. The latest tools is mounting the /system as read only and doesn't allow to be remounted as read write
回答1:
Got the same problem and I'm working on Android tools 25.1.7. How can I easily downgrade tools without getting errors in running AVD's ?
EDIT: There is in fact some problem with 25.1.7 Android tools, I updated my tools to 25.2 rc1 in Android SDK Manager (Tools (Preview Channel) tab) and now adb remount works. Thanks for question Nehal, without it I will be still fighting with adb remount (probably without success)!
来源:https://stackoverflow.com/questions/38354753/not-able-to-update-etc-hosts-file-on-android-studio-x86-and-x86x64-emulator