INDExOS / media-for-mobile

Media for Mobile
Other
456 stars 178 forks source link

File Not Found Using targetSdkVersion 24 (Android Nougat) #62

Closed mikewalkerjr closed 6 years ago

mikewalkerjr commented 7 years ago

Since changing my app's targetSdkVersion to > 23, I'm not able to transcode anymore. I've modified my code to use FileProvider, however when I attempt to transcode, I receive the exception:

file:/storage/emulated/0/DCIM/Camera/VIDEO_20170523_080806775651908.mp4: open failed: ENOENT (No such file or directory)

Before updating the targetSdkVersion, I was able to transcode properly, but when I change SDK and update the code using FileProvider, I can't transcode anymore. Is there any plan in the near future for this library to target SDK 24 and above?

johan-steffens commented 6 years ago

From sdk version 23 it is required for developers to check some permissions at runtime, rather than just declaring them in the manifest.

You can have a look at this document (https://developer.android.com/training/permissions/requesting.html) to get a sense of how to do this. You'll need to request Manifest.permission.WRITE_EXTERNAL_STORAGE, and Manifest.permission.READ_EXTERNAL_STORAGE to be able to write to and read from the SD card.

mikewalkerjr commented 6 years ago

Yes I have the required runtime permission checks for reading and writing external storage. The code works perfect when I have the SDK version set to 23, but when I go to 24 or 25 that's when the issue occurs. SDK 23 does require the runtime permission checks and works, just later SDKs don't work.

UPDATE With further research, the media-for-mobile library was not the source of the problem. Android itself started requiring using FileProvider for creating new files. For anyone who might run into this issue in the future, the link which helped me out is

https://inthecheesefactory.com/blog/how-to-share-access-to-file-with-fileprovider-on-android-nougat/en

johan-steffens commented 6 years ago

Awesome, thanks for sharing your solution!