Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Improve this questionOriginal close reason(s) were not resolved
The INSTALL_FAILED_INSUFFICIENT_STORAGE
error is the bane of every Android developer's life. It happens regardless of app size, or how much storage is available. Rebooting the target device fixes the problem briefly, but it soon comes back. There are hundreds (if not thousands) of message board posts from people asking why the problem occurs, but the folks at Google are frustratingly silent on the issue.
There is a simp开发者_Go百科le workaround. If your test device is running Android 2.2 or later then add the android:installLocation
attribute to your application's manifest file, with the value "preferExternal"
. This will force the app to be installed on the device's external storage, such as a phone's SD card.
For example:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.andrewsmith.android.darkness"
android:installLocation="preferExternal"
This is more of a band-aid than a fix, and it may not be ideal if you want your finished app to install on the device's internal memory. But it will at least make the development process a lot less frustrating.
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 first time an app is installed:
The APK file is saved as
/data/app/<full.package.name>-1.apk (1.apk)
When the app is to be updated:
The updated APK file is saved as:
/data/app/<full.package.name>-2.apk (2.apk)
The first version (1.apk) gets deleted.
On our next update(s):
- The new APK is saved as (1.apk) and (2.apk) is deleted (Repeat forever).
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:
adb shell "pm uninstall <full.packge.name>"
adb shell "rm -rf /data/app/<full.package.name>-*"
OR
Uninstall the app
Use your favorite method to delete BOTH:
/data/app/<full.package.name>-1.apk
/data/app/<full.package.name>-2.apk
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
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.
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 with
cd /data
ls -a -l -R
And 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.
The following helps:
Open a shell to the device
adb shell
Navigate to the temp directory where the incoming APK is first copied
cd /data/local/tmp
List the available files and delete as desired
rm * // use at your own risk, good practice to list files first
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.
I have solved it by including android:installLocation="auto"
inside <manifest>
tag in AndroidManifest.xml file.
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,
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nasir.phonegap"
android:installLocation="preferExternal" >
I tried the following:
- Restarted my device
- Deleted previous APK
- Rebuild my APK
- Uninstall my previous copy in the device
- Reinstall
Check if it works the same with you.
A related issue on the emulator is when there isn'y any space left in the /data
partition.
For example,
% 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
Here is a sample view of the /data/app
directory:
% 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
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,
adb shell rm /data/app/com.brooklynmarathon.calendarapi2-1.apk
In my case failure was caused by com.android.providers.media
app. I faced this on x86 android emulator. What did I do:
$ adb shell df
Filesystem Size Used Free Blksize
...
/data 224M 209M 14M 4096
....
Too low free space on /data
$ adb shell du /data
...
409870 /data/data/com.android.providers.media
...
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.
$ adb shell pm clear com.android.providers.media
Success
$ adb shell df
Filesystem Size Used Free Blksize
...
/data 224M 8M 215M 4096
...
Disk was cleared and app installed successfully.
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:
adb shell pm set-install-location 2
Makes install impossible on many apps that can't install externally (such as adblock + or so)
Then the solution is
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
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:
- You've been working using a physical device (in my case, Samsung Galaxy Ace),
- You've been developing for a couple of days straight,
- Your phone was connected all the time, day and night.
- You started getting this error after a couple of days, and it kept getting worse.
- None of the other answers worked for you.
- You're as resigned as I was...
Then, try this:
- Unplug your phone when you're not working!
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.
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:
emulator -avd <emulator name> -partition-size 1024
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.
Emulator solution
Open your .Android
directory. Usually in your home directory. Then go to avd
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 with wipe user data
checked. Your emulator should now have the new size.
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.
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.
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 from adb install
fixed the issue for me.
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.
Make sure you don't connect your android device with usb while trying to run the emulator
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).
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.
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:
for x in *.apk; do pm install -r $x; done
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.
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.
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:
cd /Very/Long/Path/To/Package/
adb install mypackage.apk
instead of
adb install /Very/Long/Path/To/Package/mypackage.apk
And it worked...installed just fine.
Just thought this might help someone else.
In my case it got fixed by increasing the extended memory of eclipse, by changing the value of -Xmx768m in eclipse.ini
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.
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".
A bit time consuming, but it should work in any case:
- Install a file manager, like Adao Task Manager, on your phone.
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.
精彩评论