Bug 21740 - Loading Image from File fails in Android, but works in iOS and Windows Phone
Summary: Loading Image from File fails in Android, but works in iOS and Windows Phone
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.2.2
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2014-07-31 16:53 UTC by Jon Douglas [MSFT]
Modified: 2015-05-19 17:14 UTC (History)
6 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Jon Douglas [MSFT] 2014-07-31 16:53:07 UTC
Within this sample project, Android will throw an unhandled exception if it tries to load an image from file, however it will work just fine with loading an image from resources in a PCL.

To test:
Run on iOS/Windows Phone/Android

Notice Android crashes with unhandled exception and seeing loading.png is within the drawing folder as the appropriate build action.

You can then remove the splashImage from the LoadingScreen to see it runs just fine and therefore seems isolated to the like of code:

			splashImage.Source = Device.OnPlatform
				ImageSource.FromFile("loading.png"), //Failing on android
Comment 1 Jon Douglas [MSFT] 2014-07-31 16:55:44 UTC
Comment 2 Parmendra Kumar 2014-08-08 08:04:22 UTC
I have tried to reproduce this issue and reproduce this with given code on Comment1.
I observe that the sample project fine on iOS, Android will throw an unhandled exception.

Zip Xamarin Logs :https://gist.github.com/Parmendrak/09d743126a386fee5bc8

Environment info:
Microsoft Visual Studio Professional 2013
Version 12.0.30501.00 Update 2
Microsoft .NET Framework
Version 4.5.51641

Xamarin (0b2a123923812a88ed3091909478dbe9e0111f00)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android
Comment 3 Michael 2015-05-19 17:14:44 UTC
I have verified, with Xamarin.Forms 1.4.2, Android projects can load images from file using Device.OnPlatform. The image files loaded were stored in the Resources>drawables folder.