如何在牛轧糖中运行的Android Studio模拟器中编辑/etc/hosts文件? [英] How to edit /etc/hosts file in Android Studio emulator running in nougat?

查看:158
本文介绍了如何在牛轧糖中运行的Android Studio模拟器中编辑/etc/hosts文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何在牛轧糖中运行的android studio模拟器中编辑/etc/hosts文件吗?我将对其进行编辑,以便可以在本地Web服务器中使用虚拟主机.我尝试通过使用adb的终端对其进行编辑,但是它返回的是只读文件系统.也尝试使用chmod,但仍然失败.

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.

更新: 我也尝试过使用adb拉和推文件 $ ./adb -s emulator-5554 push〜/Desktop/hosts/system/etc/hosts

Update: I also tried pulling and pushing files using adb $ ./adb -s emulator-5554 push ~/Desktop/hosts /system/etc/hosts

adb:错误:无法将"/Users/Christian/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

推荐答案

通过使用-writable-system启动仿真器并使用adb remount重新安装仿真器,我能够编辑/etc/hosts文件.之后,模拟器内的主机文件是可编辑的.我尝试推送/替换文件并成功.

I was able to edit the /etc/hosts file by launching the emulator with -writable-system and remounting the emulator using adb remount. After that the hosts file inside the emulator is editable. I tried pushing/replacing the file and succeeded.

这篇关于如何在牛轧糖中运行的Android Studio模拟器中编辑/etc/hosts文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆