You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何在Android Studio中冷启动API 27及以上版本的模拟器?

Force Cold Boot for API 27+ Android Emulators

Absolutely, you can still set your API 27+ emulators to always cold boot—Google just moved the option around a bit. Here are three solid ways to make this your default behavior, so you can avoid those snapshot-related headaches you mentioned:

1. Edit the AVD's config file directly

This is the most permanent fix:

  • Find your AVD's folder:
    • Windows: C:\Users\<YourUsername>\.android\avd\<YourAVDName>.avd\
    • macOS/Linux: ~/.android/avd/<YourAVDName>.avd/
  • Open the config.ini file with any text editor
  • Add this line anywhere in the file (I usually put it near the top for easy reference):
    fastboot.forceColdBoot=yes
    
  • Save the file, restart Android Studio, and your emulator will now cold boot every single time you launch it.

2. Launch via command line with a cold boot flag

If you prefer a flexible, on-demand approach, use the terminal to start your emulator with the no-snapshot flag:

  • Navigate to your Android SDK's emulator directory (e.g., ~/Library/Android/sdk/emulator/ on macOS)
  • Run this command, replacing <YourAVDName> with the exact name of your emulator:
    emulator -avd <YourAVDName> -no-snapshot-load
    

The -no-snapshot-load flag skips loading any saved state and forces a fresh cold boot. You can even create a shortcut or script for this to save time.

3. Disable snapshot auto-save in the emulator settings

If you want to turn off snapshots entirely so closing the emulator doesn't save state at all:

  • Launch your emulator, then click the three-dot menu (⋮) in the emulator's toolbar
  • Go to Settings > Snapshots
  • Toggle off the Auto-save current state to snapshot option
  • Now when you close the emulator, it won't go through that "saving state" process, and it'll cold boot the next time you open it.

All these methods should eliminate those frustrating issues you ran into—like connection timeouts, graphical glitches, logcat disconnects, and garbled SharedPreferences data—since you're starting with a fresh emulator state every time.

内容的提问来源于stack exchange,提问作者Nerdy Bunz

火山引擎 最新活动