Here is link to reproduce issue https://github.com/F0rc0sigan/MvvmCrossImageNotLoadingTestApp
Setup Xamarin.Forms project with mvvmcross
Add image on page
Image is not shown, though without mvvmcross it is shown as expected
It should load image and show it on page
It does not show image. In output it write
"FileImageSourceHandler: Could not find image or image file was invalid: File: xamarin_logo.png" Screenshot of problem: http://take.ms/YJ7aF
If i remove mvvmcross from project, then image is shown as expected
Related to this issue on StackOverflow https://stackoverflow.com/questions/48944590/xamarin-forms-not-displaying-images-in-mvvmcross-mvxcontentpage?noredirect=1#comment86318999_48944590
Debug
Version: 6.0.0-beta.7
Platform:
Can you PR this sample to the playground?
@martijn00 Thanks for your quick response. I dont get what you mean. Implement sample in playground or just add my sample to playground folder as separate solution and create pull request?
I mean implement this in the playground.
I had the same problem. The core cause of it is that MvvmCoss Setup's FormsApplication property initializes Xamarin.Forms with the wrong assembly for resources. Thus, Xamarin.Form's ResourceManager will resolve Drawable and Resource class instances from Android.* namespace, not from yours. Hence, Xamarin.Forms will be trying to resolve images not from YourProject.Resources but from Android.Resources.
However, there is a fast fix for this if you want. In your MainActivity, before base.OnCreate() call, just initialize ResourceManager again like this ResourceManager.Init(GetType().Assembly);
Any chance someone can add an example of this to the playground forms droid sample and submit a PR that shows the issue. I can assist with a fix but would appreciate help creating a repro in the sample projects.
@nickrandolph In develop branch, playground project's RootPage.xaml contains image with MvvmCross logo which is not loaded. Instead, in debug logs, you receive [0:] FileImageSourceHandler: Could not find image or image file was invalid: File: MvvmCross
I suppose, it already shows the issue :)
Awesome. Thanks will investigate
The issue appear to be that the top activity wasn't being returned at the point where the FormsApplication was initialized. I've adjusted the logic to use the first viewassembly, which is set when the Setup instance is created.
Most helpful comment
The issue appear to be that the top activity wasn't being returned at the point where the FormsApplication was initialized. I've adjusted the logic to use the first viewassembly, which is set when the Setup instance is created.