Open SandrineRY opened 4 years ago
Did you update your file provider to the androidx version? https://github.com/jamesmontemagno/MediaPlugin#android-required-setup
Yes, again and again, I checked a multiple time... (sorry for my late reply).
I have just found a workaround :). Thanks to this blog post : https://commonsware.com/blog/2019/06/07/death-external-storage-end-saga.html
So, if I add android:requestLegacyExternalStorage="true"
to my <application>
element in the manifest, the exception disapears and my app doesn't crash anymore!
In conclusion, I was right, it is the getExternalStoragePublicDirectory method that poses the problem in your code... (check the API reference)
(sorry for my poor english) I recently migrated my project to the AndroidX SDK and after having tested my app, I can see that the TakePhoto functionality does not work on AndroidX when we want to save the file in album / gallery (see below). This works well on Android 9. I noticed the same behavior and this exception with another feature in my app (custom feature). After having searched for a long time, tested the authorizations, the permissions (with xamarin essentials), the prerequisites for this plugin, ... I have found the problem : I use the getExternalStoragePublicDirectory in my code and now this is a depricated API. On the documentation, we can read that the path returned by this method is no longer accessible by the app : https://developer.android.com/reference/android/os/Environment#getExternalStoragePublicDirectory(java.lang.String). I checked your code and I saw that you use also this method in MediaPickerActivity.GetOutputMediaFile. Thus can you maybe use the getExternalFilesDir instead? Thanks for your works :)
Bug Information
Version Number of Plugin: 5.0.1 Device Tested On: Android 10, Android 9 Simulator Tested On: Version of VS: 16.5.4 Version of Xamarin: 4.6.0.726 Versions of other things you are using: Xamarin.Essentials 1.5.3.1
Steps to reproduce the Behavior
Expected Behavior
The photo is take, save in album and there is no exception in console.
Actual Behavior