Android Forms Image gif动画不';我不能在安卓上玩

Android Forms Image gif动画不';我不能在安卓上玩,android,xamarin.forms,animated-gif,Android,Xamarin.forms,Animated Gif,我是Xamarin的新手,我尝试在图像控件中播放Gif。在我的iOS模拟器中,它工作得很好,但当我在Android模拟器中启动应用程序时,gif无法播放。我不使用遗留渲染器,但我从未指定使用快速渲染器(但我认为我不必这样做)。 这是我的XAML文件: <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class

我是Xamarin的新手,我尝试在图像控件中播放Gif。在我的iOS模拟器中,它工作得很好,但当我在Android模拟器中启动应用程序时,gif无法播放。我不使用遗留渲染器,但我从未指定使用快速渲染器(但我认为我不必这样做)。 这是我的XAML文件:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Connect.Views.SplashPage">
<ContentPage.Content>
    <StackLayout Margin="20,35,20,20">
        <Image Source="splashAni.gif" VerticalOptions="CenterAndExpand"
               HorizontalOptions="Center" IsAnimationPlaying="True"/>
    </StackLayout>
</ContentPage.Content>


我不知道怎么了,希望你能帮助我,提前谢谢

这里的游戏有点晚了,但我可以用它来测试一些场景。这是一个链接到GitHub上源代码的基本示例

我怀疑您的资源可能未包含在Android项目中,并且无法找到该文件。在Gerald的示例中,他的动画gif分别位于
AnimatedGifForms.Android\Resources\drawable
AnimatedGifForms.iOS\Resources

虽然你提到它在iOS中对你有用。也许值得你花时间看看他的简单例子,并将其与你正在做的事情进行比较

关于这一点:

我尝试使用他的示例的修改版本加载动画gif,该gif是项目NetStandard共享库中的嵌入资源,但没有成功。我使用的是
ImageSource.FromStream(()=>assembly.GetManifestResourceStream(resourcePath))IsAnimationPlaying
属性必须不存在),但当我在xaml中添加/设置
IsAnimationPlaying
属性时,Android应用程序会崩溃如下:

=================================================================
    Native Crash Reporting
=================================================================
Got a SEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

No native Android stacktrace (see debuggerd output).

=================================================================
    Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x8c83a896):
0x8c83a886  10 8d 4d e4 8b 4d 10 89 4d e4 8d 4d e4 8b 4d e4  ..M..M..M..M..M.
0x8c83a896  89 4c 24 08 89 44 24 04 89 3c 24 8b c0 e8 c0 fe  .L$..D$..<$.....
0x8c83a8a6  ff ff 89 45 c4 8b 4d f0 8d 64 24 00 90 90 90 8b  ...E..M..d$.....
0x8c83a8b6  45 c4 e9 77 00 00 00 8b 4d f0 8d 64 24 00 90 90  E..w....M..d$...

=================================================================
    Managed Stacktrace:
=================================================================
      at Xamarin.Forms.Platform.Android.FormsAnimationDrawable:LoadImageAnimationAsync <0x0012e>
      at Xamarin.Forms.Platform.Android.FormsAnimationDrawable:LoadImageAnimationAsync <0x0013f>
      at Xamarin.Forms.Platform.Android.FormsAnimationDrawable:LoadImageAnimationAsync <0x0013f>
      at Xamarin.Forms.Platform.Android.FormsAnimationDrawable:LoadImageAnimationAsync <0x0013f>
      at Xamarin.Forms.Platform.Android.FormsAnimationDrawable:LoadImageAnimationAsync <0x0013f>
      at Xamarin.Forms.Platform.Android.FormsAnimationDrawable:LoadImageAnimationAsync <0x0
.....
      at Xamarin.Forms.Platform.Android.FormsAnimationDrawable:LoadImageAnimationAsync <0x0013f>
      at Xamarin.Forms.Platform.Android.FormsAnimationDrawable:LoadImageAnimationAsync <0x0013f>
      at Xamarin.Forms.Platform
.Android.FormsAnimationDrawable:LoadImageAnimationAsync <0x0013f>
      at Xamarin.Forms.Platform.Android.StreamImagesourceHandler:LoadImageAnimationAsync <0x0005b>
      at <UpdateBitmap>d__2:MoveNext <0x00768>
      at System.Runtime.CompilerServices.AsyncTaskMethodBuilder:Start <0x00127>
      at Xamarin.Forms.Platform.Android.ImageViewExtensions:UpdateBitmap <0x001bf>
      at Xamarin.Forms.Platform.Android.ImageViewExtensions:UpdateBitmap <0x00067>
      at <TryUpdateBitmap>d__6:MoveNext <0x0028f>
      at System.Runtime.CompilerServices.AsyncTaskMethodBuilder:Start <0x00147>
      at Xamarin.Forms.Platform.Android.FastRenderers.ImageElementManager:TryUpdateBitmap <0x0019b>
      at <OnElementChanged>d__3:MoveNext <0x004b7>
      at System.Runtime.CompilerServices.AsyncVoidMethodBuilder:Start <0x00127>
      at Xamarin.Forms.Platform.Android.FastRenderers.ImageElementManager:OnElementChanged <0x0015f>
      at System.EventHandler`1:invoke_void_object_TEventArgs <0x00143>
      at Xamarin.Forms.Platform.Android.FastRenderers.ImageRenderer:OnEl
ementChanged <0x0011b>
      at Xamarin.Forms.Platform.Android.FastRenderers.ImageRenderer:Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement <0x005d7>
      at Xamarin.Forms.Platform.Android.Platform:CreateRenderer <0x0013f>
      at Xamarin.Forms.Platform.Android.VisualElementPackager:AddChild <0x00487>
      at Xamarin.Forms.Platform.Android.VisualElementPackager:SetElement <0x00837>
      at Xamarin.Forms.Platform.Android.VisualElementPackager:Load <0x00057>
      at Xamarin.Forms.Platform.Android.VisualElementRenderer`1:SetPackager <0x00077>
      at Xamarin.Forms.Platform.Android.VisualElementRenderer`1:SetElement <0x007b7>
      at Xamarin.Forms.Platform.Android.VisualElementRenderer`1:Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement <0x00187>
      at Xamarin.Forms.Platform.Android.Platform:CreateRenderer <0x0013f>
      at Xamarin.Forms.Platform.Android.VisualElementPackager:AddChild <0x00487>
      at Xamarin.Forms.Platform.Android.VisualElementPackager:SetElement <0x00837>
      at Xamarin.Forms.Platform
.Android.VisualElementPackager:Load <0x00057>
      at Xamarin.Forms.Platform.Android.VisualElementRenderer`1:SetPackager <0x00077>
      at Xamarin.Forms.Platform.Android.VisualElementRenderer`1:SetElement <0x007b7>
      at Xamarin.Forms.Platform.Android.VisualElementRenderer`1:Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement <0x00187>
      at Xamarin.Forms.Platform.Android.Platform:CreateRenderer <0x0013f>
      at Xamarin.Forms.Platform.Android.AppCompat.Platform:AddChild <0x000b3>
      at Xamarin.Forms.Platform.Android.AppCompat.Platform:SetPageInternal <0x00297>
      at Xamarin.Forms.Platform.Android.AppCompat.Platform:SetPage <0x0067f>
      at Xamarin.Forms.Platform.Android.FormsAppCompatActivity:InternalSetPage <0x001b7>
      at Xamarin.Forms.Platform.Android.FormsAppCompatActivity:SetMainPage <0x00077>
      at Xamarin.Forms.Platform.Android.FormsAppCompatActivity:LoadApplication <0x0067b>
      at AnimatedGifForms.Droid.MainActivity:OnCreate <0x00143>
      at Android.App.Activity:n_OnCreate_Landroid_os_Bundle_ <0
x000ab>
      at Android.Runtime.DynamicMethodNameCounter:8 <0x000c3>
      at Android.Runtime.DynamicMethodNameCounter:8 <0x000b3>
=================================================================
[HotReload] (2020-05-29 10:24:00.4): ERROR: Caught exception in AgentStatusChangedHandler at 212: Xamarin.HotReload.DebuggerTimeoutException: Failed to Inject Assembly
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
=================================================================
本机崩溃报告
=================================================================
在执行本机代码时获得SEGV。这通常表明
mono运行时或某个本机库中出现致命错误
由您的应用程序使用。
=================================================================
没有本机Android stacktrace(请参阅debuggerd输出)。
=================================================================
基本故障地址报告
=================================================================
本机指令指针(0x8c83a896)周围的内存:
0x8c83a886 10 8d 4d e4 8b 4d 10 89 4d e4 8d 4d e4 8b 4d e4..M..M..M..M..M..M..M。

0x8c83a896 89 4c 24 08 89 44 24 04 89 3c 24 8b c0 e8 c0 fe.L$…D$…我花了一整天在这上面。据我所知,大多数GIF实际上并不以Xamarin形式工作。当它们没有首先崩溃时,它们只是显示为单帧静态图像。即使它确实可以工作(这似乎只适用于简单的应用程序,比如示例应用程序),加载图像也需要5秒以上的时间


该功能已完全损坏,应避免使用。

您是否将isAnimationPlaying设置为true?正如您在代码中看到的,是的,我将其设置为抱歉。我没看到。您是否使用其他gif进行过测试?您的xamarin.forms版本是什么?在MainActivity中有这一行(
global::Xamarin.Forms.Forms.SetFlags(“UseLegacyRenders”);
)吗?如果是的话,你应该删除它。我一整天都在思考这个问题,我一定是做错了什么,因为微软肯定不会在没有测试你是否可以实际加载/预加载动画gif支持的情况下发布动画gif支持,因为这几乎是任何人实现该功能的唯一方式。不,他们很烂。感谢您将其记录为xamarin.forms github上的一个bug,顺便说一句: