2401_88803267 2025-01-14 18:25 采纳率: 0%
浏览 294

uniapp 读写手机存储权限缺少文件权限?

离线打包开启权限缺少文件权限

img


云打包开启权限会有文件权限

img


云打包打开红框内所有文件都可以获取到本地路径,离线打包只能在(绿框)手机内部存储获取,这是什么原因?

img

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

        <!-- 读写权限 -->
        <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <application
        android:allowBackup="true"
        android:allowClearUserData="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:supportsRtl="true"
        android:requestLegacyExternalStorage="true">
        <activity
            android:name="io.dcloud.PandoraEntry"
            android:configChanges="orientation|keyboardHidden|keyboard|navigation"
            android:label="@string/app_name"
            android:launchMode="singleTask"
            android:hardwareAccelerated="true"
            android:theme="@style/TranslucentTheme"
            android:screenOrientation="user"
            android:exported="true"
            android:windowSoftInputMode="adjustResize" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="io.dcloud.PandoraEntryActivity"
            android:launchMode="singleTask"
            android:configChanges="orientation|keyboardHidden|screenSize|mcc|mnc|fontScale|keyboard|smallestScreenSize|screenLayout|screenSize|uiMode"
            android:hardwareAccelerated="true"
            android:permission="com.miui.securitycenter.permission.AppPermissionsEditor"
            android:screenOrientation="user"
            android:theme="@style/DCloudTheme"
            android:exported="true"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <action android:name="android.intent.action.VIEW" />
                <data android:scheme=" " />
            </intent-filter>
        </activity>
        <meta-data
            android:name="dcloud_appkey"
            android:value="8bde2da98fa33f1e" />
        <meta-data android:name="DCLOUD_WRITE_EXTERNAL_STORAGE" android:value="always"/>
    </application>
</manifest>

  • 写回答

3条回答 默认 最新

  • 道友老李 JWE233286一种基于机器视觉的水表指针读数识别及修正的方法 专利发明者 2025-01-14 18:26
    关注
    让【道友老李】来帮你解答,本回答参考gpt编写,并整理提供,如果还有疑问可以点击头像关注私信或评论(小黑屋了,无法评论,请私信)。
    如果答案让您满意,请采纳、关注,非常感谢!
    根据提供的xml文件内容,可以看到在``标签中声明了读写外部存储的权限: ```xml ``` 在``标签中,有一行`android:requestLegacyExternalStorage="true"`,这个属性的作用是指定应用程序是否具有对基于文件的 URI 的传统存储访问。 根据官方文档的解释,`android:requestLegacyExternalStorage="true"`为`true`时,应用程序将在存储空间文档目录之外无法直接访问其媒体文件。这意味着应用程序只能在其私有目录中访问存储的文件,而不是在SD卡中的其他文件。 因此,离线打包只能在绿框内的手机内部存储获取文件路径,而云打包可以获取红框内的所有文件路径,这是由于`android:requestLegacyExternalStorage="true"`属性设置的不同导致的。 如果想要离线打包也能在SD卡中访问其他外部存储文件路径,需要将`android:requestLegacyExternalStorage`属性设置为`false`,以启用新的存储访问框架。 ```xml ... ```
    评论

报告相同问题?

问题事件

  • 创建了问题 1月14日