简体   繁体   English

Android 模拟器快照标志不起作用

[英]Android Emulator snapshot flag not working

Android Emulator snapshot flag is not working as expected. Android 模拟器快照标志未按预期工作。 I created a new avd with name Mydevice using我创建了一个名为 Mydevice 的新 avd 使用

tools/bin/avdmanager create avd --force --name Mydevice --abi google_apis/x86 --package 'system-images;android-29;google_apis;x86' --device "Nexus 6P" &

Now I run this avd using现在我运行这个 avd 使用

sudo emulator/emulator -avd Mydevice  -no-window -port 5554

After emulator is booted successfully, I take a snapshot using模拟器启动成功后,我使用

adb -s emulator-5554 emu avd snapshot save Snap1

which successfully creates the snapshot.成功创建快照。

Now I stop my running emulator using现在我停止我正在运行的模拟器使用

adb -s emulator-5554 emu kill

Now I again run the emulator using -read-only flag and using the saved snapshot using现在我再次使用 -read-only 标志并使用保存的快照运行模拟器

sudo emulator/emulator -avd Mydevice -read-only -no-window -port 5554 -snapshot ~/.android/avd/Mydevice.avd/snapshots/Snap1

but it seems like -snapshot is getting ignored as emulator is still taking same time as earlier to boot.但似乎 -snapshot 被忽略了,因为模拟器仍然需要与之前相同的时间来启动。

I also tried removing the read only flag but that did not helped.我也尝试删除只读标志,但这没有帮助。

The argument to -snapshot is a snapshot tag name, not a path. -snapshot的参数是快照标记名称,而不是路径。

First, list the snapshots like this:首先,像这样列出快照:

emulator/emulator -avd mydevice -snapshot-list

which will produce output like this (so far I haven't figured out how to list snapshots without actually starting the emulator as well, but for now just shut down the emulator after running this command):这将产生这样的输出(到目前为止,我还没有弄清楚如何在不实际启动模拟器的情况下列出快照,但现在只需在运行此命令后关闭模拟器):

ID        TAG                 VM SIZE                DATE       VM CLOCK
--        snap_2020-12-03_13-31-29    90M 2020-12-03 13:31:29   01:11:57.073
--        default_boot            68M 2020-12-03 14:15:33   00:02:08.928

Then, start the emulator using one of the values in the "TAG" column eg:然后,使用“TAG”列中的值之一启动模拟器,例如:

emulator/emulator -avd mydevice -snapshot snap_2020-12-03_13-31-29

For Android Studio, the "advanced settings" for devices in the AVD Manager also have a drop-down for selecting a snapshot to start the device with.对于 Android Studio,AVD 管理器中设备的“高级设置”也有一个下拉菜单,用于选择启动设备的快照。

As a side note, I've found that starting an emulator image from a snapshot drastically improves its performance, at least on my Linux box.附带说明一下,我发现从快照启动模拟器映像可以极大地提高其性能,至少在我的 Linux 机器上是这样。 With the snapshot flag, the emulator's disk writes are normal -- without it, for some reason the emulator is essentially constantly writing to disk, slowing everything to a crawl.有了快照标志,模拟器的磁盘写入是正常的——没有它,出于某种原因,模拟器本质上是不断地写入磁盘,使一切变得缓慢。 I honestly don't know why that is.老实说,我不知道这是为什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM