MediaPlugin: [Android] TakePhotoAsync - IllegalArgumentException: failed to find configured root
Hey James,
I’m running into issues with the TakePhotoAsync method. They don’t occur on iOS, nor on Android with Target SDK 23.
Note: all ‘MY_PACKAGE_NAME’ found below are actually containing the correct package. 😉
I’ve read both:
- issue 312
- Settings the external path in file_paths.xml to ‘Pictures’ as specified in the readme throws the exception.
- Settings the external path in file_paths.xml to ‘Android/data/MY_PACKAGE_NAME/files/Pictures’ throws the exception.
- issue 326
- This seems to occur when you don’t add the entries to the manifest / file_paths.xml as specified in the readme.
Bug Information
Version Number of Plugin: 2.6.2 Device Tested On: Samsung S8 (Android 7.0), iPhone 5s Simulator Tested On: n.a. Version of VS: Visual Studio 2017 15.3 Version of Xamarin: 2.3.4.267 Versions of other things you are using: Plugin.Permissions 1.2.1
Steps to reproduce the Behavior
Everything should be setup as described in the readme:
- Target Android SDK is 25, so:
- xml folder was created under Resources
- file_paths.xml was created under that xml folder
- the provider was added to the manifest, where the package name placeholder was replaced with my own package name.
Create a view and view model where the view model holds an ICommand to handle, e.g. a button click. Call the TakePhotoAsync in the handler.
Expected Behavior
The camera dialog will be opened and allows you to take a picture.
Actual Behavior
An exception is thrown:
Java.Lang.IllegalArgumentException: Failed to find configured root that contains /storage/emulated/0/Android/data/MY_PACKAGE_NAME/files/Pictures/IMG_20170823_130231.jpg
The ‘Pictures’ folder was created, both on the internal and external storage. There’s just no image.
Code snippet
// Call this from the ICommand
private async Task TakePhoto()
{
var options = new StoreCameraMediaOption();
var media = await CrossMedia.Current.TakePhotoAsync(options);
}
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 20 (7 by maintainers)
Have you read my comment? Sorry, it got corrupted somehow. It should’ve read:
I had the same problem. You need to change the file_paths.xml. It must read:
<external-path …>
instead of:
<external-files-path …>
At least that works for me…