1

I have developed a Xamarin.Forms application using Visual Studio 2019. This targets iOS and Android. I have currently being developing in Debug mode.

The application contains many svg images which are loaded using the FFImageLoading.Svg.Forms plugin as follows:

SvgCachedImage imageSearch = new SvgCachedImage
{
    Source = "resource://AppName.Resources.add_red.svg",
    WidthRequest = 25,
};

These are all saved under the AppName/Resources folder. Each item's properties are as follows:

resource properties

This works perfectly in the Android simulator, on an Android Phone and also on an iPhone simulator, all in Debug mode.

I have now tried to create an Android APK in Release mode.

The APK installs onto the Android phone. The application loads without any error, but all of the items in the Resources folder are not displayed? All other elements are displayed.

I have tried:

  • Code shrinker: None
  • Linking: Sdk and User Assemblies

Any ideas or suggestions on what could be causing this?

Versions:

  • Xamarin.Essentials (1.3.1)
  • Xamarin.Forms (4.3.0.819712-pre2)
  • Xamarin.FFImageLoading.Svg.Forms (2.4.11.982)
Saamer
  • 4,687
  • 1
  • 13
  • 55
Martin Evans
  • 45,791
  • 17
  • 81
  • 97
  • Hey Martin! What happens when in Release confug you link none, No code shrinking, use dx compiler? – Saamer Oct 08 '19 at 17:29
  • @Saamer, that hasn't made a change – Martin Evans Oct 08 '19 at 18:17
  • Ok i assume that you had cleaned all cached folders including bin & obj. What's the differences between the Release and Debug configuration files & option settings? – Saamer Oct 08 '19 at 18:20
  • I have now tried cleaning out bin/obj and a full clean/rebuild, no luck. I've not spotted any obvious differences between `Debug` and `Release` settings. – Martin Evans Oct 08 '19 at 19:27
  • Can you share your code? Or a repo with a tinier reproducible version of your problem? – Saamer Oct 08 '19 at 19:28
  • 1
    I might have to try and recreate the problem with a minimal example. I have just recreated it with a direct deployment (i.e.no Archive/APK steps just a direct Run). I'm wondering if the app name is somehow different causing the resource location to be different. – Martin Evans Oct 08 '19 at 19:44
  • 1
    Hmm I wish i could help you more, all i can think of is some sort of build arguments or perhaps dig into the csproj files to make sure nothings different. – Saamer Oct 08 '19 at 19:49
  • I know it's possible. Can you share your csproj file vor at least part oft it? – AlexS Oct 09 '19 at 16:24
  • I am currently rebuilding the whole app using a new project (copying over all cs files from the old). At least the settings will all then be default, I will retest with that. If that fails I will try a simple one page app, if that fails I'll post that. – Martin Evans Oct 09 '19 at 17:10

2 Answers2

2

After a lot of rummaging around and testing lots of different settings, the solution was to create a completely new solution. I was not able to find a setting that was causing the problem:

  1. Create a new Xamarin Forms project.
  2. Copy all the original .cs and .xaml files into the new project folder. Don't copy the .csproj files.
  3. Add all the resources back into the corresponding folders.

The application was then first tested in Debug mode, then in a Release emulator. All SVG graphics loaded correctly.

Finally, an Archive and APK was made and tested on an Android phone, all worked perfectly and as expected.

I have absolutely no idea of the actual cause of this problem, but this workaround definitely saved me.

Martin Evans
  • 45,791
  • 17
  • 81
  • 97
1

I have had a similar problem. In my particular case, i was using Dotfuscator for the xamarin android project in release, and as soon as i disabled this, the menu items started to show.