1

I'm getting this error after the permission was allowed and the activity was recreated.

I/AppCompatDelegate: The Activity's LayoutInflater already has a Factory installed so we can not install AppCompat's
     W/EGL_emulation: eglSurfaceAttrib not implemented
     W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x9e23f960, error=EGL_SUCCESS
     W/System.err: java.io.IOException: open failed: EACCES (Permission denied)
     W/System.err:     at java.io.File.createNewFile(File.java:939)
     W/System.err:     at java.io.File.createTempFile(File.java:1004)

and

 E/AndroidRuntime: java.lang.NullPointerException: file
 E/AndroidRuntime:     at android.net.Uri.fromFile(Uri.java:452)

The code for asking for permission is:

     if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED ||
                    ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
         ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
     }

After the crash when I start the app I do not see the permission dialog and everything works fine, I can open the Camera with intent. I'm using Emulator. Nexus 5 API 23.

SpyZip
  • 5,511
  • 4
  • 32
  • 53
  • This error is not related to Android permissions. It seems to be a file system related issue `java.io.IOException: open failed: EACCES (Permission denied)`. – Thomas R. Oct 15 '15 at 09:40
  • Possible, but next time I try it is working fine after permission is granted. – SpyZip Oct 15 '15 at 10:53
  • 2
    It's a well known bug. The permissions WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE are granted only after the app is closed and opened again. – greywolf82 Oct 15 '15 at 14:10

2 Answers2

2

This seems to be a bug in Android M. Might be only on the emulator though.

This is a link to the issue on google dev forums. https://code.google.com/p/android-developer-preview/issues/detail?id=2982

The owner says:

Since the issue exists still in emulator 6.0, reopening the issue But working fine on MRA58K devices

I'm still seeing this on the emulator as well.

mogile_oli
  • 2,148
  • 2
  • 21
  • 21
1

If you add the CAMERA permission to your manifest, but the user hasn’t granted it at runtime, you will notice that the external intent to capture a photo will fail and throw a SecurityException.

https://plus.google.com/+AndroidDevelopers/posts/e9kyM7VXajz

Yashdeep Patel
  • 3,090
  • 1
  • 17
  • 21