修改Android 模擬器 hosts 檔

修改Android 模擬器 hosts 檔

下午為了讓我的Android模擬器連得到開發機的網站,可以說是測到快暈倒。先是搞不懂adb shell 怎麼用,再來是奇怪的directory not empty的錯誤…

 

首先,adb 這個工具的位置是在:C:\Program Files (x86)\Android\android-sdk\platform-tools (64bit的安裝路徑,我還呆呆的跑去開手機上面的終端機…)

因為模擬器預設都會以最小的記憶體開啟,所以在開啟模擬器的時候要先指定空間,後面才可以執行修改檔案的動作。

 

在網路上有查到有人碰到同樣的狀況,不過他出現的錯誤訊息是:(2.0 & 2.1)

failed to copy 'hosts' to '/system/etc/hosts': No space left on device
failed to copy 'hosts' to '/system/etc/hosts': Out of memory

 

而我的是:(2.2)

failed to copy 'hosts' to '/system/etc/hosts': Directory not empty

SNAGHTML1ec05b4

試了半天,要不是去確認了空間大小,根本不覺得和空間大小有關係Orz

SNAGHTML1e671bf

(搞不好其它版本又是其它錯誤?)

 

以下是詳細的修改指令:

emulator –avd <<your-avd-name> -partition-size 128 '開啟模擬器,先調整空間大小

adb remount '調整成可修改系統檔

adb pull /system/etc/hosts '把模擬器上的hosts檔export 出來

adb push hosts /system/etc/hosts '把修改後的hosts檔copy 回去

 

Dotblogs 的標籤: