Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 10 years ago.
The community reviewed whether to reopen this question 2 years ago and left it closed:
Original close reason(s) were not resolved
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(30)
这只是一个临时解决方法,而不是真正的解决方案。
在我遇到这种情况并且对当前的反应不满意之后,我去上班了
试图从 AOSP 源中找出答案。我找到了一个真实解决方案。
说明
首先,介绍一些关于 Android 如何安装和更新的背景知识
我们大多数人遇到的问题是在更新应用程序但删除旧 APK 失败时发生的。它本身还不会导致更新失败,但它确实会导致
/data/app
中有两个 APK 文件。下次您尝试更新应用程序时,系统无法移动其临时文件,因为 (1.apk) 和 (2.apk) 都不为空。由于 File#renameTo(File) 不会抛出异常,而是返回一个布尔值 PackageManager,因此它没有任何方法来告诉它为什么返回 INSTALL_FAILED_INSUFFICIENT_STORAGE,即使失败与可用空间量无关。
解决方案
运行:
或
卸载应用程序
使用您喜欢的方法删除两者:
确保没有其他内容以类似的方式阻止将来的安装。就我而言,我有一个
/data/app-lib/-1
目录徘徊!在这种情况下,安装到 SD 卡 可以正常工作,随后也可以移动到内部存储器。 (创建/data/app-lib/
而没有-1
结尾。)为什么其他“解决方案”有效
代码安装到外部存储的代码明显不同,不会出现相同的问题
卸载应用程序只会删除其中一个版本的 APK 文件<代码> /数据/应用程序。这就是为什么您可以重新安装一次,但不能更新它。
发生此错误时,模拟器中的可用空间量并不真正相关
This is only a temporary workaround and not a real fix.
After having this happen to me and not being pleased with the current responses I went to work
trying to figure it out from the AOSP source. I have found a REAL solution.
Explanation
First off, a bit of (simplified) background on how Android installs and updates
The issue that most of us are having happens when the application is updated, but deleting of the old APK fails. Which itself does not yet cause the update to fail, but it does cause there to be two APK files in
/data/app
.The next time you try to update the app the system can't move its temporary file because neither (1.apk) nor (2.apk) are empty. Since File#renameTo(File) doesn't throw an exception but instead returns a boolean PackageManager, it doesn't have any way to tell why it returns INSTALL_FAILED_INSUFFICIENT_STORAGE even though the failure had nothing to do with the amount of free space.
Solution
Run:
OR
Uninstall the app
Use your favorite method to delete BOTH:
Make sure nothing else blocks future installs in a similar way. In my case I had a
/data/app-lib/<full.package.name>-1
directory lingering around! In this case, an install to the SD card worked, and a subsequent move to internal memory, too. (Creating/data/app-lib/<full.package.name>
without the-1
ending.)Why other "solutions" worked
The code for installing to external storage is significantly different which does not have the same problems
Uninstalling the app only deletes one version of the APK file in
/data/app
. That's why you can reinstall it once, but not update it.The amount of free space in an emulator isn't really relevant when this bug occurs
您需要增加Android模拟器的内存容量。有两种方法:
右键单击 Android 项目的根目录,转到“运行方式”,然后转到“运行配置...”。在左侧树中找到“Android 应用程序”节点,然后选择您的项目并转到窗口右侧的“目标”选项卡,向下查找“其他模拟器命令行选项”字段(有时您会我需要使窗口更大)并最后粘贴“-partition-size 1024”。单击“应用”,然后单击“运行”以使用模拟器。
转到 Eclipse 的首选项,然后选择“启动”添加“- “默认模拟器选项”字段中的“分区大小 1024”。单击“应用”并照常使用模拟器。
You need to increase the Android emulator's memory capacity. There are two ways for that:
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.
以下内容有帮助:
打开设备的 shell
导航到首次复制传入 APK 的临时目录
列出可用文件并根据需要删除
到目前为止,这在实际设备上对我来说是可靠的。
编辑:事实证明,这种解决方案不如上面的解决方案可靠。
我尝试了多种解决方案。没有任何帮助。最后我找到了一个名为 SD Maid 的应用。这很有帮助。
它说该功能在未root的设备上受到限制。我的问题是根深蒂固的,所以很高兴能听到人们的意见,它在这些情况下是有效的,如果它对我有用只是侥幸(无论如何,这是一个不可预测的问题)。
注意:我与该应用程序无关。刚刚通过搜索找到了它。
The following helps:
Open a shell to the device
Navigate to the temp directory where the incoming APK is first copied
List the available files and delete as desired
This has been reliable for me so far on an actual device.
EDIT: This turned out to be not as reliable a solution as the one above.
I tried a number of the solutions. Nothing really helped. Finally I found an app called SD Maid. That helped.
It says the functionality is limited on unrooted devices. Mine is rooted so it would be good to see hear from people effective it is in those scenarios and if it was just a fluke that it worked for me (it is an unpredictable problem anyway).
NOTE: I have nothing to do with the app. Just found it with a search.
感谢您发布这个问题。我有一些额外的见解可能会对一些开发人员有所帮助。
我正在设备(不是模拟器)上调试我的应用程序。该设备在
/data
上有 21MB 可用空间(如执行“adb shell”时“df”显示的那样),而我的应用程序只有 5MB。但是,我确实发现,如果我删除了设备上的其他应用程序(没有重新启动手机或重新启动 adbd),INSTALL_FAILED_INSUFFICIENT_STORAGE 会消失一段时间,然后又回来。因此,调试我的 5 MB 应用程序似乎需要
/data
中的 20 MB 空间,此外,每次调试应用程序时都会泄漏一些东西。所以我执行了“adb shell”并列出了整个
/data
目录,然后我查看了 5000 行输出以了解所有空间都去了哪里。
我在设备上的
/data/klog
目录中发现了大量浪费的空间,这些空间以几个月前的调试会话中的旧日志文件的形式存在。这些不是我的日志文件:它们是由 Android 基础设施的某些部分创建的。
我删除了它们并立即节省了 58 MB 的空间,这些空间在“设置”应用程序中并未归属于任何特定应用程序。我的设备很小,所以 58MB 非常重要(大约 40%)。
到目前为止,多次运行后我还没有再次获得 INSTALL_FAILED_INSUFFICIENT_STORAGE 。我们希望这是真正的问题,尽管OP表示他的设备有足够的空间(但没有说有多少)。
希望你们中的一些人也能够通过定期删除
/data/klog/*
来逃避 INSTALL_FAILED_INSUFFICIENT_STORAGE。或者,您至少可以在
/data
中执行ls -a -l -R
来查看所有空间的去向,如果确实有一些(隐藏的)空间问题。Thanks for posting this question. I have some additional insights that may help some developers.
I am debugging my application on a device (not the emulator). The device has 21 MB free on
/data
(as revealed by "df" when doing "adb shell") and my app is only 5 MB. However, I did find that if I deleted other apps on the device (without rebooting the phone or restarting adbd), INSTALL_FAILED_INSUFFICIENT_STORAGE would go away for a while and then come back.So it seems that debugging my 5 MB app requires more like 20 MB of space in
/data
, and in addition something was leaking each time I debugged my app.So I did "adb shell" and listed the ENTIRE
/data
directory withAnd I looked at the 5000-line output to see where all the space was going.
I discovered vast quantities of wasted space on my device in the
/data/klog
directory in the form of old log files from months-old debugging sessions.These were not my log files: they were created by some part of the Android infrastructure.
I deleted them and instantly saved 58 MB which was not attributed in the Settings app to any particular app. I have a small device so 58 MB is very significant (about 40%).
So far, I have not gotten INSTALL_FAILED_INSUFFICIENT_STORAGE again after many runs. Let's hope that was the real issue, though the OP suggests that his device had plenty of space (but didn't say how much).
Hopefully some of you will also be able to escape INSTALL_FAILED_INSUFFICIENT_STORAGE by periodically deleting
/data/klog/*
.Or, you can at least do the
ls -a -l -R
in/data
to see where all your space is going, if indeed there is really some (hidden) space issue.我通过在 AndroidManifest.xml 文件中的
标记中包含android:installLocation="auto"
解决了这个问题。I have solved it by including
android:installLocation="auto"
inside<manifest>
tag in AndroidManifest.xml file.我在应用程序的清单文件中添加了一行额外的内容,即
android:installLocation="preferExternal"
。通过使用此行,它会强制将应用程序安装到外部存储。请参阅下面的示例,I had added an additional line to the application's manifest file, which is
android:installLocation="preferExternal"
. by using this line it forces to install the app to the external storage. see the example below,我尝试了以下操作:
检查它是否适合您。
I tried the following:
Check if it works the same with you.
模拟器上的一个相关问题是
/data
分区中没有剩余空间。例如,
以下是
/data/app
目录的示例视图:我删除了额外的 APK 文件。似乎每次安装都会得到一个新的 APK 文件。只需删除多余的 APK 文件即可。
例如,
A related issue on the emulator is when there isn'y any space left in the
/data
partition.For example,
Here is a sample view of the
/data/app
directory:I removed the extra APK files. It seems upon every install you get a new APK file. Just remove the extra APK files.
For example,
就我而言,失败是由
com.android.providers.media
应用程序引起的。我在 x86 android 模拟器上遇到了这个问题。我做了什么:/data
上的可用空间太低几乎所有空间都被单个应用程序消耗了!这是系统应用程序,所以我认为最好不要删除它。相反,我清理了应用程序数据。
磁盘已清除,应用程序安装成功。
In my case failure was caused by
com.android.providers.media
app. I faced this on x86 android emulator. What did I do:Too low free space on
/data
Almost all was consumed by single app! It's system app so I consider better not to delete it. Instead I cleaned up app data.
Disk was cleared and app installed successfully.
回答本主题的第一篇文章...
症状:某些应用程序无法安装,说没有空间
事实上,内部和外部存储都有足够的可用空间!
解决方案:默认禁用外部安装。
默认设置外部安装:
使得许多无法外部安装的应用程序无法安装(例如adblock +等)
然后解决方案是
或者
Answering to the very first post of this topic...
Symptom : Some app don't install, saying there is no space
and in reallity there is plenty of space free on both internal and external storage !!!
Solution: disable external installation by default.
Setting external install by defaut with this:
Makes install impossible on many apps that can't install externally (such as adblock + or so)
Then the solution is
Or
我写这篇文章感觉有点奇怪,但我不能 100% 确定在某些情况中它是不正确(它对我有用)。如果您有以下症状:
那么,试试这个:
我拔掉手机插头,让它休息一整天。我的电池有点磨损了。之后我重新连接并再次开始调试。这次一切顺利!我的意思是真的很好,就像以前一样。
此错误是否可能是由于某些电池相关的硬件造成的?这样想仍然感觉很奇怪,但现在我时不时地断开手机连接(并且在晚上)并且问题没有再出现。
I feel a bit weird writing this, but I can't be 100% sure that it's not true in some cases (it worked for me). If you had the following symptoms:
Then, try this:
I unplugged my phone and let it rest for ENTIRE DAY. My battery wore off a little. After this, I reconnected it and started debugging again. Everything worked fine this time! And I mean really REALLY fine, just as before.
Is it possible that this error might be due to some battery-related hardware stuff? It still feels weird thinking this way, but now I keep disconnecting my phone every now and then (and for the night) and the problem didn't return.
由于这个问题仍然存在,我想我应该添加一些内容 RacZo 的答案用于开发目的。如果您不使用 Eclipse 插件或出于任何原因不使用有源代码,但只有 .apk,您可以在启动模拟器时使用相同的选项从命令行增加分区大小:
据我所知,此选项没有在developer.android.com上记录,所以我我想我会把它发布在这里,这样人们就可以找到这个解决方案。
As this issue still exists, I thought I'd add something to RacZo's answer for development purposes. If you're not using the Eclipse plugin or for whatever reason you don't have the source, but just the .apk, you can increase the partition size from the command line using the same option when you launch the emulator:
As far as I know, This option is not documented at developer.android.com, so I thought I'd post it here so people might find this solution.
模拟器解决方案
打开您的
.Android
目录。通常在您的主目录中。然后转到avd
,然后打开包含您要更改的 avd 名称的目录。现在编辑
config.ini
文件并添加以下行或修改以下行:disk.dataPartition.size=1024
其中
1024
是您想要使用的大小(以 MB 为单位)。保存文件,然后启动模拟器并选中擦除用户数据
。您的模拟器现在应该具有新的大小。Emulator solution
Open your
.Android
directory. Usually in your home directory. Then go toavd
and then open the directory that has the name of the avd you would like to change.Now edit the
config.ini
file and add the following line or modify the following line:disk.dataPartition.size=1024
Where
1024
is the size you would like to use in MB. Save the file and then start your emulator withwipe user data
checked. Your emulator should now have the new size.三星 Galaxy Ace 在其规格中宣传 158MB 内部存储,但核心应用程序和服务消耗了大约 110MB(我使用设备上的任务管理器来检查这一点)。我的应用程序有 52MB,因为它有很多资源。当我删除其中一些文件到 45MB 后,该应用程序就成功安装了,没有出现任何问题。该设备仍然提醒我内部存储空间即将满,我应该卸载一些应用程序,即使我只安装了一个应用程序。
安装 .apk 捆绑包的发布版本然后卸载后,我的设备显示 99 MB 的可用空间,因此可能是调试信息弄乱了设备。请参阅Louis Semprini 的回答。
Samsung Galaxy Ace advertises 158 MB of internal storage in its specifications, but the core applications and services consume about 110 MB of that (I used the task manager on the device to inspect this). My app was 52 MB, because it had a lot of assets. Once I deleted some of those down to 45 MB, the app managed to install without a problem. The device was still alerting me that internal storage was almost full, and I should uninstall some apps, even though I only had one app installed.
After installing a release version of the .apk bundle and then uninstalling it, my device displays 99 MB of free space, so it might be debugging information cluttering up the device after all. See Louis Semprini's answer.
解决方案很简单。
打开 AVD 管理器。编辑您的 AVD。
在硬件部分下方,列出了一些属性,其右侧列出了“新建...”和“删除”。
按新建。选择数据分区大小。设置为“512MB”(MB 是必需的)。你就完成了。如果仍然遇到问题,请使用相同的方法也增加系统和缓存分区。
这一切都记录在这里:
http://developer.android.com/guide/developing/devices/managing -avds.html
The solution is simple.
Open up the AVD Manager. Edit your AVD.
Down in the hardware section, there are some properties listed with "New..." and "Delete" to the right of it.
Press New. Select Data Partition size. Set to "512MB" (the MB is required). And you're done. if you still get issues, increase your system and cache partitions too using the same method.
It's all documented right here:
http://developer.android.com/guide/developing/devices/managing-avds.html
只需从命令行卸载模拟器中的应用程序或转到设置并卸载应用程序即可。这将阻止错误的发生。
Just uninstall the application from emulator either from command line or go to settings and uninstall the application. This will stop the error from coming.
我在使用新的 Nexus 4 和使用 Adobe AIR 构建的 APK 时遇到了这个问题。我的清单中已经有 android:installLocation="preferExternal" 。我注意到我还使用
-s
选项调用adb install
(在共享大容量存储上安装包,例如 sdcard。)这似乎有点矫枉过正。从
adb install
中删除-s
标志解决了我的问题。I ran into this problem with my new Nexus 4 and an APK built with Adobe AIR. I already had android:installLocation="preferExternal" in my manifest. I noticed I was also calling
adb install
with the-s
option (Install package on the shared mass storage such as sdcard.) which seemed like overkill.Removing the
-s
flag fromadb install
fixed the issue for me.我遇到这个问题是因为我使用 Sideload Wonder Machine 将应用程序安装到我的实际手机时遇到此错误。我发现问题是 /payload 目录中有多个 .apk 文件。我以为这是受支持的东西,但是当我删除除一个 .apk 之外的所有内容时,错误就消失了。
I came across this question because I was getting this error using the Sideload Wonder Machine to install apps to my actual phone. I found the problem was that I had multiple .apk files in the /payload directory. I thought this was something that was supported, but when I removed all but one .apk, the error went away.
确保在尝试运行模拟器时没有将 Android 设备与 USB 连接
Make sure you don't connect your android device with usb while trying to run the emulator
解决方法:
编译为 2.1,不使用
android:installLocation="preferExternal"
。好的?
编译为 2.2,包括
android:installLocation="preferExternal"
。这仍然会安装在低于 8 的 SDK 版本上(XML 标记被忽略)。
Workaround:
Compile as 2.1 without
android:installLocation="preferExternal"
.OK?
Compile as 2.2 including
android:installLocation="preferExternal"
.This will still install on SDK version less than 8 (the XML tag is ignored).
如果您使用的是真实设备,那么您只会耗尽内部内存。只需进入 Android 设置 -> 应用程序,并将某些应用程序移动到SD卡或卸载某些应用程序。
如果您使用的是模拟器,请参阅 RacZo 的回答。
If you're using a real device, you've simply run out of internal memory. Just go to Android settings -> Applications, and move some apps to the SD card or uninstall some apps.
If you're using the emulator, see RacZo's answer.
当我尝试使用以下命令在 SD 卡 目录中批量安装大约 50 个应用程序时,遇到了同样的错误完整 ROM 更新后的 ADB shell:
其中一些已安装,但许多都失败并出现错误 INSTALL_FAILED_INSUFFICIENT_STORAGE 。所有失败的应用程序名称中都有空格。我批量重命名它们并再次尝试。这次一切都成功了。我没有做重启或任何事情。可能这不是你们面临的问题,但这可能会帮助那些与我面临同样问题的人。
I came across the same error when I tried to batch install about 50 apps in the SD card directory using the ADB shell after a full ROM update:
Some of them installed, but many failed with the error INSTALL_FAILED_INSUFFICIENT_STORAGE. All the failed apps had space in their name. I batch renamed them and tried again. It all worked this time. I did not do reboot or anything. May be this is not the problem you guys are facing, but this might help someone searching with the same problem as I faced.
如果您在模拟器上运行应用程序,并且此问题仍然存在,请检查您的通知管理器。如果它显示一个图标和有关“手机内存已满”的通知,则意味着您已经在模拟器上安装了很多应用程序。从“设置>>管理应用程序>>选择应用程序>>卸载”中卸载当前不需要的多个应用程序。
那套。
现在重新运行该程序。
If you are running your application on an emulator, and if this problem persists, check your notification manager. If it shows you an icon and notification about "Phone memory is full", that means you have already installed so many applications on your emulator. Uninstall several applications which you don't want currently from "Settings >> Manage Application >> Select Application >> Uninstall".
That Set.
Now re-run the program.
今天,我在使用手机使用 Eclipse 进行测试/调试时遇到此错误。
我的错误是我在应用程序名称中使用了挪威语特殊字符(“æ”、“ø”、“å”)。当我重构应用程序名称(使用“o”而不是“ø”)时,应用程序已正确安装。
可能不是您的问题,但可能会引起其他人遇到相同错误的注意。
I got this error today, when using my phone for testing/debugging with Eclipse.
My error was that I used Norwegian special character ("æ", "ø", "å") in the application name. When I refactored the app name (using "o" instead of "ø") the app was installed correctly..
Probably not your problem, but could be note for other people getting the same error.
在尝试了该线程中的其他所有内容后,我发现自己的问题是因为 .apk 文件的路径太长。所以我 cd'ed 到 .apk 所在的目录并执行:
而不是
And it Works...installed just good。
只是认为这可能对其他人有帮助。
After trying out everything else in this thread, I found out my own problem was because the path to the .apk file was too long. So I cd'ed to the directory where the .apk was in and did:
instead of
And it worked...installed just fine.
Just thought this might help someone else.
就我而言,它是通过增加 eclipse 的扩展内存、更改 eclipse.ini 中的 -Xmx768m 的值来解决的。
In my case it got fixed by increasing the extended memory of eclipse, by changing the value of -Xmx768m in eclipse.ini
我最终从设备上卸载了该应用程序,然后将其重新安装回 Eclipse 中。这是我在经常使用设备时经常遇到的问题,但今天我从开发中收到了该消息。
I ended up uninstalling the app from the device and then re-installing it back in Eclipse. This is a problem I get all the time on my device from regular use, but today I got that message from development.
我也遇到了同样的问题,我做了“恢复出厂设置”,之后效果很好。
I too faced the same problem, and I did a "Factory data reset", and it worked fine after that.
我的手机没有 root 访问权限,并且没有准备好将我的应用程序安装在 SD 卡上。
/data/
上有 15 MB 的可用空间,而我的应用程序的空间不足 2 MB。有一段时间我还过得去;清理 Eclipse 项目并重新启动手机,但最终停止工作(可能在更新)。
清理我的应用程序缓存已经解决了我的问题,并且不需要重新启动手机或卸载应用程序。
市场上有一些应用程序可用于一次清除多个应用程序的缓存。搜索“干净”。
I didn't have root access on my phone and am unprepared for my app to be installed on the SD card. 15 MB of space is available on
/data/
and my application is under 2 MB.For a while I got by; cleaning the Eclipse project and restarting the phone, but eventually that stopped working (probably after an update).
Cleaning my application cache has solved the problem for me and doesn't require a restart of the phone or uninstallation of the app.
There are applications on the market which you can use to clear the cache of multiple applications at once. Search for "clean".
有点耗时,但在任何情况下都应该有效:
通过 USB 连接并启用 USB 存储。将 APK 文件从本地版本复制到手机(您可能需要允许应用程序设置下的未知来源)。
然后只需点击 APK 文件,Android 就会安装它。就像我说的,这很耗时,但可能比时不时重新启动要快。
A bit time consuming, but it should work in any case:
Connect via USB and enable USB storage. Copy the APK file from your local build to the phone (you might need to allow unknown sources under application settings).
Then just tap the APK file and Android will install it. Like I said, it's time consuming, but it might be faster than rebooting every now and then.