LoginSignup
9
6

More than 5 years have passed since last update.

いまどきのAndroid Emulatorの/systemをリマウントしhostsを書き換える

Posted at

やりたいことは、
俺達のAndroid Emulatorでローカルに立てたサーバにアクセスする方法
そのものなんですが、いまどき(SDK 25.3.0)のエミュレーターだとそのままでは書き込めないみたいです。

まず、普通に。

$ adb shell
$ su
# mount -o rw,remount /system
# mount 
/dev/block/vda on /system type ext4 (rw,seclabel,relatime,data=ordered)

一瞬リマウントできたかのように見えるけど、結局書き換えられずリードオンリーに戻ってる。リトライしてみると、

# mount -o rw,remount /system
'/dev/block/vda' is read-only

と怒られたりもする。

このあたりにでていたように

# mount -o rw,remount -t ext4 /dev/block/vda /system

とやっても同じでした。

ググってできたのが結局これ。
How to edit /etc/hosts file in Android Studio emulator running in nougat?

$ adb root && adb remount && adb push ./hosts /system/etc/.

合わせ技でやらないとだめっぽいです。

ただし、Emulator(adb)を再起動するともとに戻っちゃいますのであらからず。

9
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
6