【Debug-File】Android10報錯:open failed: EACCES (Permission denied)

訪問相冊時報錯:

open failed: EACCES (Permission denied)

解決辦法:

1.在AndroidManifest.xml已經聲明瞭讀寫權限:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

在代碼中動態申請以上讀寫權限(略)

 

2. 在AndroidManifest.xml中聲明關閉存儲權限的限制

android:requestLegacyExternalStorage="true"

設置位置:

<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"
        android:requestLegacyExternalStorage="true">

 

【參考】https://blog.csdn.net/weixin_40093242/article/details/104067573    # 安卓10報錯:open failed: EACCES (Permission denied) 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章