SkiaSharp.Extended icon indicating copy to clipboard operation
SkiaSharp.Extended copied to clipboard

[BUG] SKLottieView Not Displaying In Android Release Mode

Open Sohel3798 opened this issue 1 year ago • 12 comments

SKLottieView Not Displaying In Android Release Mode

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

Sohel3798 avatar Sep 28 '23 10:09 Sohel3798

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

JimmyPun610 avatar Dec 20 '23 22:12 JimmyPun610

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

ThumbGen avatar Dec 22 '23 08:12 ThumbGen

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

The MAUI one

JimmyPun610 avatar Dec 22 '23 21:12 JimmyPun610

No workaround?

diegolv avatar Dec 30 '23 00:12 diegolv

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

ThumbGen avatar Jan 01 '24 16:01 ThumbGen

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.

JimmyPun610 avatar Jan 09 '24 00:01 JimmyPun610

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 :/

ThumbGen avatar Jan 09 '24 07:01 ThumbGen

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}" />

JimmyPun610 avatar Jan 23 '24 00:01 JimmyPun610

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

ThumbGen avatar Jan 28 '24 11:01 ThumbGen