Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failure INSTALL_FAILED_MEDIA_UNAVAILABLE

I've installed JDK, Android SDK and Mono Android for Visual Studio 2010, I've created an empty solution and I got the emulator up and running with Android 2.3.3 - so far so good.

When I try to deploy (F5) the app to the emulator, it connects to the emulator, and all goes fine until it starts "Installing the platform framework". Then it loads for several minutes, and finally throws an exception that looks like this:

enter image description here

I have tried googlin' it, but the INSTALL_FAILED_MEDIA_UNAVAILABLE doesn't seem to be described anywhere else.

I don't know if this is an important detail, but on my PC I have remapped my home folders (Documents, Favorites, Desktop, etc.) to folders like "D:\Mikkel\Dokumenter". It seemed to cause some problems when starting the emulator initially, but after adding the environment variable "ANDROID_SDK_HOME" pointing to "D:\Mikkel.android" the emulator started up with no problems.

Please advise.

like image 520
Miros Avatar asked Apr 28 '11 08:04

Miros


2 Answers

Ensure that you have enough internal and external free space in your device. You can determine the free space available with the command:

$ adb shell df
Filesystem             Size   Used   Free   Blksize
/dev                   192M    32K   192M   4096
/mnt/asec              192M     0K   192M   4096
/mnt/obb               192M     0K   192M   4096
/system                145M   124M    20M   4096
/data                  196M   167M    29M   4096
/cache                  95M    32M    62M   4096
/mnt/sdcard              3G   177M     3G   32768

In the above output, /data (which is the default install location) has 29MB free, while /mnt/sdcard (the SD card, and the external install location) has 3GB free.

For Debug builds, you need to have ~40MB free (for the Runtime package, Platform package, and apps). Release builds are significantly smaller, but Release builds cannot be created with the Evaluation version.

It's plausible that if your emulator doesn't have an SD card, then Android would generate the INSTALL_FAILED_MEDIA_UNAVAILABLE error. (To add an SD card to your emulator, start the android app, go to Virtual devices, select a device, click Edit, and look at the SD Card section.)

A cursory grepping of Android suggests that DefaultContainerService.java is the controlling factor, specifically DefaultContainerService.recommendAppInstallLocation(), and that if you're out of internal space and the package specifies auto (as Mono for Android does) and the SD card is unavailable (status.equals(Environment.MEDIA_MOUNTED) is false), then RECOMMEND_MEDIA_UNAVAILABLE is returned, which is translated into INSTALL_FAILED_MEDIA_UNAVAILABLE. This still seems odd to me (wouldn't RECOMMEND_FAILED_INSUFFICIENT_STORAGE make more sense?), but this appears to be what's happening.

like image 53
jonp Avatar answered Oct 21 '22 06:10

jonp


Possible Problems :

  1. No Internal/ External space in the Drive(or sdcard).
  2. Connection is lost during the installation (apk to device or emulator).

Solution :

  1. Try to create some space( remove some apps).
  2. Try to reconnect the phone/emulator restart (worked for me)
like image 40
Pramod Dutta Avatar answered Oct 21 '22 06:10

Pramod Dutta