Mediaplugin: [Android] Crash when trying to use TakePhotoAsync with targetSdk >= 24

Created on 9 Oct 2017  路  7Comments  路  Source: jamesmontemagno/MediaPlugin

Bug Information

Version Number of Plugin: 3.0.1
Device Tested On: Nexus 7 (API 22 & 23)
Simulator Tested On:
Version of VS: Last stable
Version of Xamarin: Last stable
Versions of other things you are using:

Steps to reproduce the Behavior

Set targetSdkVersion to 24 or 25 in manifest and try to use TakePhotoAsync (only tested on version < 24)

Expected Behavior

Should present the camera view

Actual Behavior

Crash with log available there https://gist.github.com/Julien-Mialon/24d3251f518d6c9e137576f51d07d324

Looking to android source for the plugin, narrowing the problem to those lines when calling FileProvider.GetUriForFile https://github.com/jamesmontemagno/MediaPlugin/blob/master/src/Media.Plugin.Android/MediaPickerActivity.cs#L156-L166

Workaround available : set targetSdkVersion to 23.

bug need-more-info

All 7 comments

Thanks for the bug report, I am able to reproduce this on Google Pixel running Android O
Marking this confirmed

Steps to reproduce:

  1. Create an Android app
  2. Set minimum Android target version to > 24
  3. Call CrossMedia.Current.TakePhotoAsync

Sorry, spoke too soon.

This is not a bug, you need to add the file provider and file_path.xml when targeting API level 24 or higher
See more info here
https://github.com/jamesmontemagno/MediaPlugin#android-n

Please reopen of the issue if you continue to have a problem

Hi, I am having the exact same issue as Julien-Mialon,

I have tried the steps in https://github.com/jamesmontemagno/MediaPlugin#android-n, but it still crashes with targetSdkVersion to 24 or 25.

The workaround, set targetSdkVersion to 23 worked for me.

@raymondchoong that's rather strange. Could you share the sample project? Make sure you delete _bin, debug, and packages_ folder when sharing the sample

I can confirm that I've experienced this issue as well. Even though I was able to display the camera, when I take the picture, the application still crashes when I return back into the application. I've tried throwing a try-catch but my application doesn't catch an exception.
I'm going to see if I can generate a log file and compare to see if you issues are similar but I can also confirm that I was only able to get the camera to display when I implemented the suggested work around.

Run the sample, works just fine. You need to add the files xml to your app

Yes. Working fine for version 24. Problem was with my file-paths.xml having the wrong tag.

Changed from <external-files-path> to <external-path>

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Glabenwitt picture Glabenwitt  路  4Comments

manonaga2188 picture manonaga2188  路  5Comments

Brosten picture Brosten  路  3Comments

MarcorOnline picture MarcorOnline  路  7Comments

irinakush picture irinakush  路  6Comments