我已经开始了一个用于测试目的的清洁项目。我尝试做的就是启用该选项将应用程序移动到SD卡。我已将android:installLocation="auto
添加到清单中,现在看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test.mysdcardpls"
android:installLocation="auto">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
将应用程序部署到我的设备后,我可以看到“移动到SD卡”选项已启用。但是,当我单击该按钮时,它会返回一条错误消息,指出我没有足够的存储空间(使用干净的16GB SD卡进行测试时)。这种情况发生在我测试的任何设备上(索尼xperia z1,华为p8 lite,三星galaxy s9)
我也尝试过使用“preferExternal”,但结果相同。 我似乎无法找到有关此问题的任何信息。有没有遇到同样问题的人?
发现问题是由Android Studio部署引起的。在设备上安装生成的APK时,它可以作为魅力。