Anyone know how to edit /etc/hosts file inside an android studio emulator running in nougat? I will be editing it so I can use my virtual host in my local web server. I tried editing it through terminal using adb however, it is returning Read-only file system. Tried also using chmod but still it fails.
Update: I also tried pulling and pushing files using adb $ ./adb -s emulator-5554 push ~/Desktop/hosts /system/etc/hosts
adb: error: failed to copy '/Users/Christian/Desktop/hosts' to '/system/etc/hosts': couldn't create file: Read-only file system
Navigate to the /system/etc directory. Locate the hosts file in this directory and long-press it to open the "Properties" menu. Select the "Change" option in the permissions section.
Right-click on the Notepad icon and select Run as administrator. In Notepad, click File then Open. In the File name field, paste c:\Windows\System32\drivers\etc\hosts . Save the changes by clicking File > Save .
1) android-sdk-macosx/tools/emulator -avd <avdname> -writable-system 2) ./adb root 3) ./adb remount 4) ./adb push <local>/hosts /etc/hosts
Android file host can be
/etc/hosts <--- This worked for me /etc/system/hosts /system/etc/hosts
Check
1) ./adb shell 2) cat /etc/hosts 3) ping customsite.com
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With