question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android] TakePhotoAsync - IllegalArgumentException: failed to find configured root

See original GitHub issue

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);
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:20 (7 by maintainers)

github_iconTop GitHub Comments

5reactions
obarteltcommented, Oct 3, 2017

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…

0reactions
PaulVrugtcommented, Apr 10, 2018

@obartelt

Right, now that i read it for the 3rd time I see you are correct. The discussion between you and jamesmontemagno seemed to go specifically about the external-files-path and external-path, and there was no more mentioning about the full path after jamesmontemagno stated you shouldn’t use the full path. That’s why I didn’t understand that this was necessary.

Anyway, good for you that you’re already using the method I (and apparently you too 😉 ) posted, since this seems to work on all devices.

@jamesmontemagno , this confirms that this seems to be the only working way. Probably a good idea to update the documentation, or provide us with an alternative solution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

IllegalArgumentException: Failed to find configured root - ...
FATAL EXCEPTION: main Process: com.example.marek.myapplication, PID: 6747 java.lang.IllegalArgumentException: Failed to find configured root ...
Read more >
Android: FileProvider IllegalArgumentException Failed to find ...
Android : Android : FileProvider IllegalArgumentException Failed to find configured root that contains /data/data/**/files/Videos/final.mp4 ...
Read more >
Android : FileProvider - Failed to find configured root - YouTube
... https://www.hows.tech/p/recommended.html ] Android : FileProvider - IllegalArgumentException : Failed to find configured root Note: The ...
Read more >
Android - geturiforfile - failed to find configured root error.
Breakpoint on the exception gives. java.lang.IllegalArgumentException: Failed to find configured root that contains /CL-Shopping-Potato Sticks.
Read more >
Untitled
Failed to find configured root that contains /storage/ WebJun 1, 2020 · Failed to ... [Android] TakePhotoAsync - IllegalArgumentException: failed to find ....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found