adb安装失败,错误为"INSTALL_FAILED_INSUFFICIENT_STORAGE"

Pra*_*abu 6 linux android adb android-sdk-tools sony-xperia

我已经购买了我的第一部Android手机索尼Xperia M而没有意识到我们无法将应用程序移动到外部SD卡的问题.有关详情,请参阅此链接.

索尼的唯一建议是根据设备,分区并使用第三方应用来移动设备.他们还提到生根可能会使保修失效.

我的Android Xperia M详细信息如下所列

Model number C1904
Android version 4.1.2
Build number 15.1.C.2.8
Run Code Online (Sandbox Code Playgroud)

我试过从一些论坛运行以下命令,它对我不起作用,

adb devices
adb shell pm get-install-location
adb shell pm set-install-location 2
Run Code Online (Sandbox Code Playgroud)

虽然上面的命令没有提示任何错误,但我可以将安装位置设置为2(使用adb shell pm get-install-location).所以我相信它设置得当.但后来我尝试安装一些应用程序,它只安装在内部存储器中.

我试过' apps2sd '实用程序移动我的应用程序,它显示以下错误,

'The device does not have a real primary external storage, or the primary external storage is emulated. Moving app to SD function cannot be supported by this device.'
Run Code Online (Sandbox Code Playgroud)

最后来自另一个论坛,我了解到我们可以通过'adb install'命令安装apk文件直接安装到sd卡中,如下所示,

adb install -s C:\com.furkan0gul.mvanparking.apk
Run Code Online (Sandbox Code Playgroud)

上面的命令失败,出现此错误,

3531 KB/s (13523837 bytes in 3.740s)
        pkg: /sdcard/tmp/com.furkan0gul.mvanparking.apk
Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE]
Run Code Online (Sandbox Code Playgroud)

我的外卡中有足够的空间(总共8GB内存超过6GB).你可以使用下面的命令找到它,

>adb shell df
Filesystem              Size    Used    Free   Blksize
/dev                    402M     64K    402M   4096
/mnt/asec               402M      0K    402M   4096
/mnt/obb                402M      0K    402M   4096
/system                1183M    907M    275M   4096
/cache                  246M      4M    241M   4096
/persist                  3M     80K      3M   4096
/firmware                63M     43M     19M   16384
/data                  2101M   1401M    700M   4096
/lta-label               15M      4M     10M   4096
/storage/sdcard0       2101M   1401M    700M   4096
/storage/sdcard1       7572M   1088M   6483M   32768
Run Code Online (Sandbox Code Playgroud)

如果我运行没有'-s'开关的adb install命令,它在内部存储器中安装正常,没有任何问题,如下所示,

> adb install C:\com.furkan0gul.mvanparking.apk
2549 KB/s (13523837 bytes in 5.180s)
        pkg: /data/local/tmp/com.furkan0gul.mvanparking.apk
Success
Run Code Online (Sandbox Code Playgroud)

在安装到SD卡时,app似乎安装在'/ sdcard'中,但在'df'命令输出中没有安装这样的东西.还尝试通过谷歌搜索此" INSTALL_FAILED_INSUFFICIENT_STORAGE ".他们中的大多数人都要求在模拟器中做一些更改才能完成这项工作.我已经卸载了应用程序,重新启动了设备,并尝试再次安装到SD卡但不能正常工作以相同的不足存储错误结束.

我没有使用模拟器.我只是直接安装apk到我的SD卡.我不想根植设备并使保修提供无效.

感谢有人可以就此发表您的想法.

小智 4

有一个简单的解决方法。如果您的测试设备运行的是 Android 2.2 或更高版本,则添加

android:installLocation 
Run Code Online (Sandbox Code Playgroud)

属性添加到应用程序的清单文件中,值为“preferExternal”。这将强制应用程序安装在设备的外部存储上,例如手机的 SD 卡。

例如:

 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.dem"
    android:installLocation="preferExternal">
Run Code Online (Sandbox Code Playgroud)