解决 Android 模拟器空间不足导致 installDebug 失败问题

解决 Android 模拟器空间不足导致 installDebug 失败问题



如果你在运行 npm run android 时遇到以下错误:

Execution failed for task ':app:installDebug'.
...
java.io.IOException: Requested internal only, but not enough space

那么问题通常很简单:

🚨 Android 模拟器空间不足


💡 问题原因

Android 虚拟设备(AVD)默认的内部存储空间通常只有 2GB–6GB,很容易被占满:

  • 多次安装 Debug APK
  • Gradle 构建缓存
  • 系统更新和缓存文件

最终导致无法再安装应用。


✅ 我的解决方法(最有效)

直接扩大模拟器存储空间:

  1. 打开 Android Studio
  2. 进入 Device Manager
  3. 编辑已有模拟器或创建新模拟器
  4. 点击 Show Advanced Settings
  5. Internal Storage 设置为 16 GB
  6. 保存并重启模拟器

设置为 16GB 后,问题即可彻底解决。


⚡ 临时解决方案

如果只是临时应急,可以:

  • 清空模拟器数据(Wipe Data)
  • 手动卸载应用:
adb uninstall your.package.name

但这些只是短期解决方案。


🧠 开发建议

  • 开发环境建议至少分配 12GB–16GB 存储
  • 关闭 Snapshot(避免保存“满磁盘状态”)
  • 定期清理构建:
cd android
./gradlew clean

✅ 总结

如果看到错误:

Requested internal only, but not enough space

不是代码问题,而是模拟器磁盘空间不足。

根本解决方案: 将 AVD 内部存储提升到 16GB。

这是最稳定、最彻底的解决办法。

❤️ Support This Blog


If this post helped you, you can support my writing with a small donation. Thank you for reading.


Comments

Popular posts from this blog

fixed: embedded-redis: Unable to run on macOS Sonoma

Copying MDC Context Map in Web Clients: A Comprehensive Guide

Reset user password for your own Ghost blog