Failure INSTALL_FAILED_MEDIA_UNAVAILABLE

后端 未结 9 1834
生来不讨喜
生来不讨喜 2021-02-12 19:22

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 go

9条回答
  •  心在旅途
    2021-02-12 19:53

    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.

提交回复
热议问题