mono / SkiaSharp.Extended

SkiaSharp is a cross-platform, comprehensive 2D graphics API for all .NET platforms. And, here is where you will find all sorts of extras that you can use with it.
https://mono.github.io/SkiaSharp.Extended
MIT License
218 stars 69 forks source link

[BUG] SKLottieView Not Displaying In Android Release Mode #228

Open Sohel3798 opened 9 months ago

Sohel3798 commented 9 months ago

SKLottieView Not Displaying In Android Release Mode

<skia:SKLottieView
    Source="loading.json"
    RepeatCount="-1"
    HeightRequest="120"
    WidthRequest="120"
    HorizontalOptions="Center" />
JimmyPun610 commented 6 months ago

having the same issue, all good in debug mode (.NET 8)

ThumbGen commented 6 months ago

Maui or Forms? I think it works well with Xamarin Forms, Android release.

JimmyPun610 commented 6 months ago

Maui or Forms? I think it works well with Xamarin Forms, Android release.

The MAUI one

diegolv commented 6 months ago

No workaround?

ThumbGen commented 6 months ago

The animations work for me in MAUI, if I drop them in the Resources/Raw folder (they'll have the MauiAsset type).

See https://cedricgabrang.medium.com/implementing-lottie-animations-in-your-net-maui-application-62bd484af651

JimmyPun610 commented 5 months ago

The animations work for me in MAUI, if I drop them in the Resources/Raw folder (they'll have the MauiAsset type).

See https://cedricgabrang.medium.com/implementing-lottie-animations-in-your-net-maui-application-62bd484af651

I have already followed the site. It works on MAUI Android Debug mode but no luck in Release mode.

ThumbGen commented 5 months ago

Strange. I've just rebuilt in Release mode and animations are working for me. So either my Release mode is not properly configured (although looking at the building steps it should be), or there's a problem on your end :/

JimmyPun610 commented 5 months ago

Just got some new findings. It will not work if we are not directly passing the file name to Source in the XAML, for example, binding the source to string will not work in android release mode. However, passing the SKLottieImageSource will work. So I use converter to do so...

 public class SKLottieImageSourceConverter : IValueConverter
 {
     public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
     {
         if (value == null)
             return null;
         return SKLottieImageSource.FromFile(value.ToString()) as SKLottieImageSource;
     }
     public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
     {
         return null;
     }
 }
                <skia:SKLottieView  Source="{Binding AnimationPath, Converter={StaticResource lottieImageConverter}}"
                                    RepeatMode="Restart"
                                    RepeatCount="-1"
                                    IsAnimationEnabled="True"
                                    HeightRequest="{Binding AnimationHeight}"
                                    WidthRequest="{Binding AnimationWidth}" />
ThumbGen commented 5 months ago

Indeed, I can confirm this, I was always using such a converter, that's why it always worked for me (in Release as well)