How to remove ReadOnly status from android emulator file system?

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-06 03:36:13

问题


I`m trying to edit my android emulator (AVD) hosts file, so it can acess a virtual host i have in my Mac OS host machine.

I try following the instructions on this link: http://borkweb.com/story/setting-etchosts-on-an-android-emulator-using-a-mac

But i keep receiving "REad Only File System" messages. I`ve tried it using Android Device Monitor, from Android Studio, but it also ReadOnly.

How can I remove the ReadOnly status from my emulator file system?


回答1:


To update the hosts file in the emulator, save the following script in the same directory as your updated "hosts" file:

#!/bin/bash
#
# While the emulator is starting up, run this script to upload a custom hosts file
#
adb remount
while [ $? -ne 0 ]
do
 sleep 1
 echo "Retrying adb remount"
 adb remount
done
adb push hosts /etc/hosts
if [ $? -ne 0 ]
then
 echo "Failed to push hosts file to android device"
else
 echo "Hosts file pushed successfully"
fi
############################################################################

Run this script when the emulator is starting up.

Verification: adb shell cat /etc/hosts

Please note: you can it only run once! If you re-run it more than once, you'll get a read-only filesystem error. If you have to re-run it again: restart the emulator beforehand.

Kudos to my colleague.



来源:https://stackoverflow.com/questions/37598209/how-to-remove-readonly-status-from-android-emulator-file-system

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!