C# 未找到乐天动画JSON动画文件异常Xamarin Android

C# 未找到乐天动画JSON动画文件异常Xamarin Android,c#,android,xamarin,xamarin.android,C#,Android,Xamarin,Xamarin.android,我正在使用Xamarin.Android进行这项工作,我已经将testanim.json文件放在了assets文件夹中。当我运行应用程序时,它总是抛出错误文件not found下面的异常是我的乐蒂动画XML代码 <com.airbnb.lottie.LottieAnimationView android:id="@+id/animation_view" android:layout_width="wrap_content" android:layout_height

我正在使用Xamarin.Android进行这项工作,我已经将testanim.json文件放在了assets文件夹中。当我运行应用程序时,它总是抛出错误文件not found下面的异常是我的乐蒂动画XML代码

<com.airbnb.lottie.LottieAnimationView
    android:id="@+id/animation_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

我的C#代码如下:

LottieAnimationView animationView = FindViewById<LottieAnimationView>(Resource.Id.animation_view);
animationView.SetAnimation("testanim.json");
animationView.Loop(true);
lottieeanimationview animationView=findviewbyd(Resource.Id.animation\u视图);
SetAnimation(“testanim.json”);
animationView.Loop(true);

我终于找到了解决方案:

问题: 资产文件夹中的yourfile.json动画文件的生成操作设置为“无”

解决方案: 右键单击yourfile.json动画文件并转到属性,然后将构建操作设置为AndroidAssets。现在在项目中构建并查看动画

注意:如果您已将文件添加到Resources/raw文件夹中,请转到json文件属性并将构建操作设置为AndroidResrouce,我已使用以下给定代码引用Resource/raw中的动画

animationView.SetAnimation(Resource.Raw.animationFile);

请记住:不要在动画文件名中使用“-”,而应使用“389;”。

我终于找到了解决方案:

问题: 资产文件夹中的yourfile.json动画文件的生成操作设置为“无”

解决方案: 右键单击yourfile.json动画文件并转到属性,然后将构建操作设置为AndroidAssets。现在在项目中构建并查看动画

注意:如果您已将文件添加到Resources/raw文件夹中,请转到json文件属性并将构建操作设置为AndroidResrouce,我已使用以下给定代码引用Resource/raw中的动画

animationView.SetAnimation(Resource.Raw.animationFile);
请记住:不要在动画文件名中使用“-”,而应使用“\u”