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"

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


当前回答

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

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

默认设置外部安装:

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

其他回答

我在我的新Nexus 4和用Adobe AIR构建的APK上遇到了这个问题。我已经有android:installLocation="preferExternal"在我的清单。我注意到我还用-s选项调用adb install(在共享大容量存储上安装包,如sdcard.),这似乎有点多余。

从adb安装中删除-s标志为我解决了这个问题。

模拟器上的一个相关问题是/data分区中没有任何剩余空间。

例如,

% adb shell df

Filesystem             Size   Used   Free   Blksize
/dev                   252M    32K   252M   4096
/mnt/asec              252M     0K   252M   4096
/mnt/obb               252M     0K   252M   4096
/system                154M   154M     0K   4096
/data                   64M    57M     6M   4096
/cache                  64M     1M    62M   4096

下面是/data/app目录的示例视图:

% adb shell ls -l /data/app

-rw-r--r-- system   system      19949 2011-10-12 17:09 CubeLiveWallpapers.apk
-rw-r--r-- system   system      27670 2011-10-12 17:09 GestureBuilder.apk
-rw-r--r-- system   system      34341 2011-10-12 17:09 SoftKeyboard.apk
-rw-r--r-- system   system      20151 2011-10-12 17:09 WidgetPreview.apk

我删除了多余的APK文件。似乎每次安装你都会得到一个新的APK文件。只需删除额外的APK文件。

例如,

adb shell rm /data/app/com.brooklynmarathon.calendarapi2-1.apk

我的手机没有root权限,也没有准备好把我的应用程序安装在SD卡上。/data/上有15 MB的可用空间,而我的应用程序不足2 MB。

有一段时间我还过得去;清理Eclipse项目并重新启动手机,但最终停止工作(可能是在更新之后)。

清理我的应用程序缓存为我解决了这个问题,不需要重新启动手机或卸载应用程序。

市场上有一些应用程序可以一次性清除多个应用程序的缓存。搜索“干净”。

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

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