Exception 'open failed: EACCES (Permission denied)' on Android

前端 未结 30 1419
[愿得一人]
[愿得一人] 2020-11-22 00:59

I am getting

open failed: EACCES (Permission denied)

on the line OutputStream myOutput = new FileOutputStream

相关标签:
30条回答
  • 2020-11-22 01:35

    I had the same problem (API >= 23).

    The solution https://stackoverflow.com/a/13569364/1729501 worked for me, but it was not practical to disconnect app for debugging.

    my solution was to install proper adb device driver on Windows. The google USB driver did not work for my device.

    STEP 1: Download adb drivers for your device brand.

    STEP 2: Go to device manager -> other devices -> look for entries with word "adb" -> select Update driver -> give location in step 1

    0 讨论(0)
  • 2020-11-22 01:36

    For anyone coming here from search results and are targeting Android 10: Android 10 (API 29) changes some permissions related to storage.

    I fixed the issue when I replaced my previous instances of Environment.getExternalStorageDirectory() (which is deprecated with API 29) with context.getExternalFilesDir(null).

    Note that context.getExternalFilesDir(type) can return null if the storage location isn't available, so be sure to check that whenever you're checking if you have external permissions.

    Read more here.

    0 讨论(0)
  • 2020-11-22 01:39

    In addition to all answers, if the clients are using Android 6.0, Android added new permission model for (Marshmallow).

    Trick: If you are targeting version 22 or below, your application will request all permissions at install time just as it would on any device running an OS below Marshmallow. If you are trying on the emulator then from android 6.0 onwards you need to explicitly go the settings->apps-> YOURAPP -> permissions and change the permission if you have given any.

    0 讨论(0)
  • 2020-11-22 01:41

    Change a permission property in your /system/etc/permission/platform.xml
    and group need to mentioned as like below.

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE">
        <group android:gid="sdcard_rw" />
        <group android:gid="media_rw" />    
    </uses-permission>
    
    0 讨论(0)
  • 2020-11-22 01:44

    It turned out, it was a stupid mistake since I had my phone still connected to the desktop PC and didn't realize this.

    So I had to turn off the USB connection and everything worked fine.

    0 讨论(0)
  • 2020-11-22 01:45

    I have observed this once when running the application inside the emulator. In the emulator settings, you need to specify the size of external storage ("SD Card") properly. By default, the "external storage" field is empty, and that probably means there is no such device and EACCES is thrown even if permissions are granted in the manifest.

    0 讨论(0)
提交回复
热议问题