Skip to content

Instantly share code, notes, and snippets.

@tw-Frey
Last active July 28, 2022 06:00
Show Gist options
  • Select an option

  • Save tw-Frey/4425a30f62a3d474009350a7e63c1e88 to your computer and use it in GitHub Desktop.

Select an option

Save tw-Frey/4425a30f62a3d474009350a7e63c1e88 to your computer and use it in GitHub Desktop.
如何 push 檔案到 Android Emulator 的 /system (USE -writable-system)

因為項目需要
要調整 /system/framework/framework-res.apk
網路上可以查到很多方法寫入 /system (下面會再補充)
但因為 Android Emulator 不斷更新
很多方法已經失效 (有的方法以前有用過能 work, 現在已經不行了)
後來注意到 這篇 (Read only file system on Android) 回應
才想起 Emulator 有個參數: -writable-system
為了寫入 system partition 新增的
要注意是

-writable-system

Use this option to have a writable system image during your emulation session. To do so:

  1. Start a virtual device with the -writable-system option.
  2. Enter the adb remount command from a command terminal to tell the emulator to remount system/ as read/write (it’s mounted as read-only by default).

Note that using this flag will create a temporary copy of the system image that can be very large (several hundred MBs), but will be destroyed when the emulator exits.

所以會有種情況就是:
使用 -writable-system 開啟 AVD 寫入資料後 關閉AVD
然後 正常地 (from GUI) 開啟 AVD 是看不到上面寫入的資料

@tw-Frey
Copy link
Author

tw-Frey commented Oct 31, 2019

參考資料

adb shell stop
adb shell mkdir /data/local/tmp/empty
adb shell mount -o bind /data/local/tmp/empty /system/app/webview
adb shell start

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment