INSTALL_FAILED_INSUFFICIENT_STORAGE错误是每个Android开发人员的烦恼。这与应用程序大小或可用存储空间大小无关。重新启动目标设备可以短暂地修复问题,但它很快就会回来。人们在留言板上发帖询问为什么会出现这个问题,但令人沮丧的是,谷歌的人对这个问题保持沉默。

有一个简单的变通办法。如果您的测试设备运行的是Android 2.2或更高版本,那么将Android:installLocation属性添加到应用程序的清单文件中,值为“preferExternal”。这将迫使应用程序安装在设备的外部存储设备上,比如手机的SD卡。

例如:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.andrewsmith.android.darkness"
          android:installLocation="preferExternal"

这更像是一种创可贴,而不是补救措施,如果你想要完成的应用程序安装在设备的内部内存中,这可能不太理想。但它至少会让开发过程不那么令人沮丧。


当前回答

只需从模拟器中从命令行卸载应用程序,或者进入设置并卸载应用程序。这将阻止错误的发生。

其他回答

我也遇到了同样的问题,我做了一个“工厂数据重置”,在那之后它工作得很好。

您需要增加Android模拟器的内存容量。有两种方法:

Right click the root of your Android Project, go to "Run As" and then go to "Run Configurations...". Locate the "Android Application" node in the tree at the left, and then select your project and go to the "Target" tab on the right side of the window look down for the "Additional Emulator Command Line Options" field (sometimes you'll need to make the window larger) and finally paste "-partition-size 1024" there. Click Apply and then Run to use your emulator. Go to Eclipse's Preferences, and then select “Launch” Add “-partition-size 1024” on the “Default emulator option” field. Click “Apply” and use your emulator as usual.

三星Galaxy Ace在其规格中宣称有158 MB的内部存储空间,但核心应用程序和服务消耗了大约110 MB的存储空间(我使用设备上的任务管理器来检查这一点)。我的应用是52 MB,因为它有很多资产。当我把其中一些文件删除到45 MB后,应用程序就可以顺利安装了。尽管我只安装了一个应用程序,但设备仍在提醒我内部存储空间快满了,我应该卸载一些应用程序。

在安装了.apk包的发布版本,然后卸载它之后,我的设备显示了99 MB的可用空间,所以可能是调试信息把设备弄得乱七八糟。请看Louis Semprini的回答。

模拟器解决方案

打开你的。android目录。通常在您的主目录中。然后转到avd,然后打开包含您想要更改的avd名称的目录。

现在编辑config.ini文件并添加以下行或修改以下行:

disk.dataPartition.size=1024

其中1024是您想要使用的MB大小。保存文件,然后启动模拟器,选中擦除用户数据。您的模拟器现在应该具有新的大小。

我已经解决了这个问题,包括android:installLocation="auto"内<manifest>标签在AndroidManifest.xml文件。