月度存档: 一月 2018

unity install location最好设置为Automatic

Unity install location,根据 unity 官方文档:https://docs.unity3d.com/Manual/class-PlayerSettingsAndroid.html

Install Location 	Specifies application install location on the device (for detailed information, refer to Android Developer documentation on install locations.
        Automatic 	Let the operating system decide. User will be able to move the app back and forth.
        Prefer External 	Install the application to external storage (SD card) if possible. The operating system does not guarantee it; if not possible, the app will be installed to internal memory.
        Force Internal 	Force the application to be installed to internal memory. The user will be unable to move the app to external storage.

项目组最初选择的是 Prefer External,本意是想尽量安装在SD卡上,不占用玩家手机内存储。

今天在一台手机上,程序死活安装不上去,抓到Log:

01-30 15:17:33.801 3109-3242/? D/PackageManager: return install result to caller: 1141892560

01-30 15:17:33.801 3109-3242/? D/PackageManager: returnCode: -18

找到PackageManager.java的源码:https://android.googlesource.com/platform/frameworks/base/+/534a67c/core/java/android/content/pm/PackageManager.java

    // ------ Errors related to sdcard
    /**
     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
     * a secure container mount point couldn't be accessed on external media.
     * @hide
     */
    public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;

然后在google上搜索 INSTALL_FAILED_CONTAINER_ERROR
http://www.cnblogs.com/lovecode/articles/3658211.html

https://stackoverflow.com/questions/5744298/what-does-this-mean-failure-install-failed-container-error

获得解决方案:


Change the install location from

android:installLocation="preferExternal"

into

android:installLocation="auto"

in your project's AndroidManifest.xml.

修改后重新出包,安装,成功。