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"

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


当前回答

当我尝试在完整的ROM更新后使用ADB shell在SD卡目录中批量安装大约50个应用程序时,我遇到了同样的错误:

for x in *.apk; do pm install -r $x; done

其中一些已经安装,但许多都失败了,出现了INSTALL_FAILED_INSUFFICIENT_STORAGE错误。所有失败的应用程序名称中都有空格。我批量重命名它们,并再次尝试。这次一切都成功了。我没做重启什么的。也许这不是你们面临的问题,但这可能会帮助那些和我面临同样问题的人。

其他回答

我觉得写这篇文章有点奇怪,但我不能100%确定在某些情况下这不是真的(这对我来说很管用)。如果您有以下症状:

你一直在使用物理设备(对我来说,是三星Galaxy Ace)工作, 你这几天都在发育, 你的手机一直都是联网的,不分昼夜。 几天后就开始出现这个错误,而且情况越来越糟。 其他答案都对你没用。 你和我一样无可奈何……

然后,试试这个:

不工作的时候拔掉手机插头!

我把手机插头拔掉,让它休息一整天。我的电池没电了。在此之后,我重新连接它并再次开始调试。这次一切都很正常!我是说真的真的很好,就像以前一样。

这个错误可能是由于一些电池相关的硬件问题吗?这样想仍然感觉很奇怪,但现在我时不时地断开手机连接(甚至是晚上),问题没有复发。

回复这个话题的第一篇文章…

症状:某些应用程序不安装,说没有空间 实际上,内部和外部存储都有足够的空闲空间!! 解决方法:默认关闭外部安装。

默认设置外部安装:

adb shell pm set-install-location 2

使安装不可能在许多应用程序不能安装外部(如adblock +或左右)

那么答案是

adb shell pm set-install-location 0

Or

adb shell pm set-install-location 1

0: auto (if one is full - or irrelevant !!! - it select the other)
1: internal
2: external

处理:

编译为2.1不含android:installLocation="preferExternal"。

OK?

编译为2.2,包括android:installLocation="preferExternal"。

这仍然会安装在SDK版本小于8的版本上(XML标记被忽略)。

您需要增加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.

我遇到这个问题是因为我使用Sideload Wonder Machine在我的实际手机上安装应用程序时遇到了这个错误。我发现问题是在/payload目录中有多个.apk文件。我认为这是支持的东西,但当我删除了所有的。apk,只有一个,错误消失了。