Coder Social home page Coder Social logo

baseflow / lottiexamarin Goto Github PK

View Code? Open in Web Editor NEW
1.2K 60.0 259.0 38.86 MB

Render After Effects animations natively on Android, iOS, MacOS and TvOS for Xamarin

Home Page: https://baseflow.com

License: Apache License 2.0

C# 100.00%
lottie airbnb android xamarin animation ios xamarin-forms bodymovin json baseflow

lottiexamarin's Introduction

LottieXamarin

Lottie is a mobile library for Android and iOS that parses Adobe After Effects animations exported as json with Bodymovin and renders them natively on mobile!

Support

  • Feel free to open an issue. Make sure to use one of the templates!
  • Commercial support is available. Integration with your app or services, samples, feature request, etc. Email: [email protected]
  • Powered by: baseflow.com

Download

Android: NuGet Badge iOS: NuGet Badge Xamarin.Forms: NuGet Badge

For the first time, designers can create and ship beautiful animations without an engineer painstakingly recreating it by hand. They say a picture is worth 1,000 words so here are 13,000:

Example1

Example2

Example3

Community

Example4

All of these animations were created in After Effects, exported with Bodymovin, and rendered natively with no additional engineering effort.

Bodymovin is an After Effects plugin created by Hernan Torrisi that exports After effects files as json and includes a javascript web player. We've built on top of his great work to extend its usage to Android, iOS, and React Native.

Read more about it on our blog post Or get in touch on Twitter (gpeal8) or via [email protected]

Sample App

You can build the sample app yourself or download it from the Play Store. The sample app includes some built in animations but also allows you to load an animation from internal storage or from a url.

Using Lottie for Xamarin.Forms

A normal sample is:

<forms:AnimationView
    x:Name="animationView"
    Animation="LottieLogo1.json"
    AnimationSource="AssetOrBundle"
    Command="{Binding ClickCommand}"
    VerticalOptions="FillAndExpand"
    HorizontalOptions="FillAndExpand" />

All possible options are:

<forms:AnimationView 
    x:Name="animationView"
    Animation="LottieLogo1.json"
    AnimationSource="AssetOrBundle"
    AutoPlay="True"
    CacheComposition="True"
    Clicked="animationView_Clicked"
    Command="{Binding ClickCommand}"
    FallbackResource="{Binding Image}"
    ImageAssetsFolder="Assets/lottie"
    IsAnimating="{Binding IsAnimating}"
    MaxFrame="100"
    MaxProgress="100"
    MinFrame="0"
    MinProgress="0"
    OnAnimationLoaded="animationView_OnAnimationLoaded"
    OnAnimationUpdate="animationView_OnAnimationUpdate"
    OnFailure="animationView_OnFailure"
    OnFinishedAnimation="animationView_OnFinishedAnimation"
    OnPauseAnimation="animationView_OnPauseAnimation"
    OnPlayAnimation="animationView_OnPlayAnimation"
    OnRepeatAnimation="animationView_OnRepeatAnimation"
    OnResumeAnimation="animationView_OnResumeAnimation"
    OnStopAnimation="animationView_OnStopAnimation"
    Progress="{Binding Progress}"
    RepeatCount="3"
    RepeatMode="Restart"
    Scale="1"
    Speed="1"
    VerticalOptions="FillAndExpand"
    HorizontalOptions="FillAndExpand" />

Using Lottie for Xamarin Android

Lottie supports Ice Cream Sandwich (API 14) and above. The simplest way to use it is with LottieAnimationView:

<com.airbnb.lottie.LottieAnimationView
        android:id="@+id/animation_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:lottie_fileName="hello-world.json"
        app:lottie_loop="true"
        app:lottie_autoPlay="true" />

Or you can load it programatically in multiple ways. From a json asset in app/src/main/assets:

LottieAnimationView animationView = FindViewById<LottieAnimationView>(Resource.Id.animation_view);
animationView.SetAnimation("hello-world.json");
animationView.Loop = true;

This method will load the file and parse the animation in the background and asynchronously start rendering once completed.

If you want to reuse an animation such as in each item of a list or load it from a network request JSONObject:

 LottieAnimationView animationView = FindViewById<LottieAnimationView>(Resource.Id.animation_view);
 ...
 LottieComposition composition = LottieComposition.Factory.FromJson(Resources, jsonObject, (composition) => 
 {
     animationView.SetComposition(composition);
     animationView.PlayAnimation();
 });

You can then control the animation or add listeners:

animationView.AddAnimatorUpdateListener(animationListener);
animationView.PlayAnimation();
...
if (animationView.IsAnimating) 
{
    // Do something.
}
...
animationView.Progress = 0.5f;
...
// Custom animation speed or duration.
ValueAnimator animator = ValueAnimator.OfFloat(0f, 1f).SetDuration(500);
animator.Update += (sender, e) => animationView.Progress = (float)e.Animation.AnimatedValue;
animator.Start();
...
animationView.CancelAnimation();

Under the hood, LottieAnimationView uses LottieDrawable to render its animations. If you need to, you can use the the drawable form directly:

LottieDrawable drawable = new LottieDrawable();
LottieComposition.Factory.FromAssetFileName(Context, "hello-world.json", (composition) => {
    drawable.SetComposition(composition);
});

If your animation will be frequently reused, LottieAnimationView has an optional caching strategy built in. Use LottieAnimationView#SetAnimation(String, CacheStrategy). CacheStrategy can be Strong, Weak, or None to have LottieAnimationView hold a strong or weak reference to the loaded and parsed animation.

You can also use the awaitable version of LottieComposition's asynchronous methods:

var composition = await LottieComposition.Factory.FromAssetFileNameAsync(this.Context, assetName);
..
var composition = await LottieComposition.Factory.FromJsonAsync(Resources, jsonObject);
...
var composition = await LottieComposition.Factory.FromInputStreamAsync(this.Context, stream);

Image Support

You can animate images if your animation is loaded from assets and your image file is in a subdirectory of assets. Just call SetImageAssetsFolder on LottieAnimationView or LottieDrawable with the relative folder inside of assets and make sure that the images that bodymovin export are in that folder with their names unchanged (should be img_#). If you use LottieDrawable directly, you must call RecycleBitmaps when you are done with it.

If you need to provide your own bitmaps if you downloaded them from the network or something, you can provide a delegate to do that:

animationView.SetImageAssetDelegate((LottieImageAsset asset) =>
{
   retun GetBitmap(asset);
});

Using Lottie for Xamarin iOS

Lottie supports iOS 8 and above. Lottie animations can be loaded from bundled JSON or from a URL

The simplest way to use it is with LOTAnimationView:

LOTAnimationView animation = LOTAnimationView.AnimationNamed("LottieLogo1");
this.View.AddSubview(animation);
animation.PlayWithCompletion((animationFinished) => {
  // Do Something
});
//You can also use the awaitable version
//var animationFinished = await animation.PlayAsync();

Or you can load it programmatically from a NSUrl

LOTAnimationView animation = new LOTAnimationView(new NSUrl(url));
this.View.AddSubview(animation);

Lottie supports the iOS UIViewContentModes ScaleAspectFit and ScaleAspectFill

You can also set the animation progress interactively.

CGPoint translation = gesture.GetTranslationInView(this.View);
nfloat progress = translation.Y / this.View.Bounds.Size.Height;
animationView.AnimationProgress = progress;

Want to mask arbitrary views to animation layers in a Lottie View? Easy-peasy as long as you know the name of the layer from After Effects

UIView snapshot = this.View.SnapshotView(afterScreenUpdates: true);
lottieAnimation.AddSubview(snapshot, layer: "AfterEffectsLayerName");

Lottie comes with a UIViewController animation-controller for making custom viewController transitions!

#region View Controller Transitioning
public class LOTAnimationTransitionDelegate : UIViewControllerTransitioningDelegate
{
    public override IUIViewControllerAnimatedTransitioning GetAnimationControllerForPresentedController(UIViewController presented, UIViewController presenting, UIViewController source)
    {
        LOTAnimationTransitionController animationController =
            new LOTAnimationTransitionController(
            animation: "vcTransition1",
            fromLayer: "outLayer",
            toLayer: "inLayer");

        return animationController;
    }

    public override IUIViewControllerAnimatedTransitioning GetAnimationControllerForDismissedController(UIViewController dismissed)
    {
        LOTAnimationTransitionController animationController = 
            new LOTAnimationTransitionController(
                animation: "vcTransition2",
                fromLayer: "outLayer",
                toLayer: "inLayer");

        return animationController;
    } 
}
#endregion

If your animation will be frequently reused, LOTAnimationView has an built in LRU Caching Strategy.

Supported After Effects Features

Keyframe Interpolation


  • Linear Interpolation

  • Bezier Interpolation

  • Hold Interpolation

  • Rove Across Time

  • Spatial Bezier

Solids


  • Transform Anchor Point

  • Transform Position

  • Transform Scale

  • Transform Rotation

  • Transform Opacity

Masks


  • Path

  • Opacity

  • Multiple Masks (additive)

Track Mattes


  • Alpha Matte

Parenting


  • Multiple Parenting

  • Nulls

Shape Layers


  • Rectangle (All properties)

  • Ellipse (All properties)

  • Polystar (All properties)

  • Polygon (All properties. Integer point values only.)

  • Path (All properties)

  • Anchor Point

  • Position

  • Scale

  • Rotation

  • Opacity

  • Group Transforms (Anchor point, position, scale etc)

  • Multiple paths in one group

Stroke (shape layer)


  • Stroke Color

  • Stroke Opacity

  • Stroke Width

  • Line Cap

  • Dashes

Fill (shape layer)


  • Fill Color

  • Fill Opacity

Trim Paths (shape layer)


  • Trim Paths Start

  • Trim Paths End

  • Trim Paths Offset

Performance and Memory

  1. If the composition has no masks or mattes then the performance and memory overhead should be quite good. No bitmaps are created and most operations are simple canvas draw operations.
  2. If the composition has mattes, 2-3 bitmaps will be created at the composition size. The bitmaps are created automatically by lottie when the animation view is added to the window and recycled when it is removed from the window. For this reason, it is not recommended to use animations with masks or mattes in a RecyclerView because it will cause significant bitmap churn. In addition to memory churn, additional bitmap.eraseColor() and canvas.drawBitmap() calls are necessary for masks and mattes which will slow down the performance of the animation. For small animations, the performance hit should not be large enough to be obvious when actually used.
  3. If you are using your animation in a list, it is recommended to use a CacheStrategy in LottieAnimationView.setAnimation(String, CacheStrategy) so the animations do not have to be deserialized every time.

Try it out

Clone this repository and run the LottieSample module to see a bunch of sample animations. The JSON files for them are located in LottieSample/src/main/assets and the orignal After Effects files are located in /After Effects Samples

The sample app can also load json files at a given url or locally on your device (like Downloads or on your sdcard).

Community Contributions

Community Contributors

Alternatives

  1. Build animations by hand. Building animations by hand is a huge time commitment for design and engineering across Android and iOS. It's often hard or even impossible to justify spending so much time to get an animation right.
  2. Facebook Keyframes. Keyframes is a wonderful new library from Facebook that they built for reactions. However, Keyframes doesn't support some of Lottie's features such as masks, mattes, trim paths, dash patterns, and more.
  3. Gifs. Gifs are more than double the size of a bodymovin JSON and are rendered at a fixed size that can't be scaled up to match large and high density screens.
  4. Png sequences. Png sequences are even worse than gifs in that their file sizes are often 30-50x the size of the bodymovin json and also can't be scaled up.

Why is it called Lottie?

Lottie is named after a German film director and the foremost pioneer of silhouette animation. Her best known films are The Adventures of Prince Achmed (1926) โ€“ the oldest surviving feature-length animated film, preceding Walt Disney's feature-length Snow White and the Seven Dwarfs (1937) by over ten years The art of Lotte Reineger

Contributing

Contributors are more than welcome. Just upload a PR with a description of your changes. Lottie uses Facebook screenshot tests for Android to identify pixel level changes/breakages. Please run ./gradlew --daemon recordMode screenshotTests before uploading a PR to ensure that nothing has broken. Use a Nexus 5 emulator running Lollipop for this. Changed screenshots will show up in your git diff if you have.

If you would like to add more JSON files and screenshot tests, feel free to do so and add the test to LottieTest.

Issues or feature requests?

File github issues for anything that is unexpectedly broken. If an After Effects file is not working, please attach it to your issue. Debugging without the original file is much more difficult.

To build the source code from command line

  • msbuild Lottie.sln /t:restore
  • msbuild Lottie.sln /p:Configuration=Release

lottiexamarin's People

Contributors

4brunu avatar adrianknight89 avatar afk013 avatar alexsorokoletov avatar anaghsharma avatar angularsen avatar azchohfi avatar campersau avatar fabionuno avatar jamesmcroft avatar jimbobbennett avatar jzeferino avatar ksemenenko avatar kxgonzalez avatar marcoscobena avatar martijn00 avatar martinapapaliska avatar matthewrdev avatar mhmd-azeez avatar modplug avatar philippd avatar rookiejava avatar roubachof avatar rustamirzaev avatar taz4270 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lottiexamarin's Issues

Is UWP supported?

Just came across this on GitHub and was wondering if Lottie is supported on UWP?

Debugging Lottie

Hi, I'm trying to get an animation to work using Lottie for Xamarin Forms. I've put the json in the Assets folder as an Android Asset. It runs with no errors, but the animation does not show.

Is there a way to debug the problem or can anyone give any ideas?

Downloaded the Lottie for Xamarin Forms 1.5.2 using Xamarin.Forms v2.3.4.224

Iโ€™m using the LottieLogo1.json in my Android Assets folder and marked the file as an AndroidAsset.

The Android project is set to compile using Android v 7.1
Target Android version set to 7.1

The project builds and runs but nothing loads on the screen.



<forms:AnimationView
x:Name="AnimationView"
Animation="LottieLogo1.json"
Loop="True"
AutoPlay="True"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand" />

Android sample crashing on pre-lollipop

On Android, the vector drawable support does not cover DrawableLeft and DrawableRight, therefore the app crashes in runtime (I've tested it in KitKat).

The crash happens because of lines like this one.

From this StackOverflow answer:

From 23.3.0 version vector drawables can only be loaded via app:srcCompat or setImageResource()

Unhandled Exception:
 Android.Views.InflateException: Binary XML file line #1: Error inflating class TextView ---> Android.Content.Res.Resources+NotFoundException: File res/drawable/ic_file.xml from drawable resource ID #0x7f02005e ---> Org.XmlPull.V1.XmlPullParserException: Binary XML file line #1: invalid drawable tag vector
    --- End of inner exception stack trace ---
    --- End of inner exception stack trace ---
   --- End of managed Android.Views.InflateException stack trace ---
 android.view.InflateException: Binary XML file line #1: Error inflating class TextView
 	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:714)
 	at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)
 	at android.view.LayoutInflater.rInflate(LayoutInflater.java:759)
 	at android.view.LayoutInflater.rInflate(LayoutInflater.java:759)
 	at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
 	at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
 	at md5e2c848f4ba844312c5e40ea7e60ca910.AnimationFragment.n_onCreateView(Native Method)
 	at md5e2c848f4ba844312c5e40ea7e60ca910.AnimationFragment.onCreateView(AnimationFragment.java:38)
 	at android.support.v4.app.Fragment.performCreateView(Fragment.java:2189)
 	at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1299)
 	at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528)
 	at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595)
 	at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:757)
 	at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2355)
 	at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2146)
 	at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2098)
 	at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2008)
 	at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:710)
 	at android.os.Handler.handleCallback(Handler.java:733)
 	at android.os.Handler.dispatchMessage(Handler.java:95)
 	at android.os.Looper.loop(Looper.java:136)
 	at android.app.ActivityThread.main(ActivityThread.java:5017)
 	at java.lang.reflect.Method.invokeNative(Native Method)
 	at java.lang.reflect.Method.invoke(Method.java:515)
 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
 	at dalvik.system.NativeStart.main(Native Method)
 Caused by: android.content.res.Resources$NotFoundException: File res/drawable/ic_file.xml from drawable resource ID #0x7f02005e
 	at android.content.res.Resources.loadDrawable(Resources.java:2101)
 	at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
 	at android.widget.TextView.<init>(TextView.java:806)
 	at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:62)
 	at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:58)
 	at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103)
 	at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1021)
 	at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1080)
 	at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:47)
 	at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:172)
 	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
 	... 26 more
 Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #1: invalid drawable tag vector
 	at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:933)
 	at android.graphics.drawable.Drawable.createFromXml(Drawable.java:877)
 	at android.content.res.Resources.loadDrawable(Resources.java:2097)
 	... 36 more
 
 [ERROR] FATAL UNHANDLED EXCEPTION: Android.Views.InflateException: Binary XML file line #1: Error inflating class TextView ---> Android.Content.Res.Resources+NotFoundException: File res/drawable/ic_file.xml from drawable resource ID #0x7f02005e ---> Org.XmlPull.V1.XmlPullParserException: Binary XML file line #1: invalid drawable tag vector
    --- End of inner exception stack trace ---
    --- End of inner exception stack trace ---
   --- End of managed Android.Views.InflateException stack trace ---
 android.view.InflateException: Binary XML file line #1: Error inflating class TextView
 	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:714)
 	at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)
 	at android.view.LayoutInflater.rInflate(LayoutInflater.java:759)
 	at android.view.LayoutInflater.rInflate(LayoutInflater.java:759)
 	at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
 	at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
 	at md5e2c848f4ba844312c5e40ea7e60ca910.AnimationFragment.n_onCreateView(Native Method)
 	at md5e2c848f4ba844312c5e40ea7e60ca910.AnimationFragment.onCreateView(AnimationFragment.java:38)
 	at android.support.v4.app.Fragment.performCreateView(Fragment.java:2189)
 	at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1299)
 	at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528)
 	at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595)
 	at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:757)
 	at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2355)
 	at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2146)
 	at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2098)
 	at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2008)
 	at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:710)
 	at android.os.Handler.handleCallback(Handler.java:733)
 	at android.os.Handler.dispatchMessage(Handler.java:95)
 	at android.os.Looper.loop(Looper.java:136)
 	at android.app.ActivityThread.main(ActivityThread.java:5017)
 	at java.lang.reflect.Method.invokeNative(Native Method)
 	at java.lang.reflect.Method.invoke(Method.java:515)
 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
 	at dalvik.system.NativeStart.main(Native Method)
 Caused by: android.content.res.Resources$NotFoundException: File res/drawable/ic_file.xml from drawable resource ID #0x7f02005e
 	at android.content.res.Resources.loadDrawable(Resources.java:2101)
 	at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
 	at android.widget.TextView.<init>(TextView.java:806)
 	at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:62)
 	at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:58)
 	at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103)
 	at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1021)
 	at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1080)
 	at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:47)
 	at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:172)
 	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
 	... 26 more
 Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #1: invalid drawable tag vector
 	at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:933)
 	at android.graphics.drawable.Drawable.createFromXml(Drawable.java:877)
 	at android.content.res.Resources.loadDrawable(Resources.java:2097)
 	... 36 more

Unrecognized selector sent to instance exception on device only

What You Are Seeing?

My app crashes with an unrecognized selector sent to class exception when running on device (iPhone5 iOS 9.3.5) but works fine on simulator.

Output Log

LottieSamples.iOS +[UIColor colorWithHexString:]: unrecognized selector sent to class 
0x386ec538
LottieSamples.iOS Xamarin.iOS: Received unhandled ObjectiveC exception: 
NSInvalidArgumentException +[UIColor colorWithHexString:]: unrecognized selector sent 
to class 0x386ec538

iOS animation view not showing sometimes

Hi, i am having a hard time tying to get the animation view to display on iOS, android it works fine but on iOS it doesn't in some layouts although it as mentioned it works fine on android.

Below is android:

android

Below is iOS:

ios

The red line is a stack layout with the animationview inside

Code is as follows below:

<RelativeLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
      <Image
          Aspect="AspectFill"
          Source="{x:Static helpers:Settings.DefaultBackgroundImage}"
          RelativeLayout.WidthConstraint= "{ConstraintExpression Type=RelativeToParent, Property=Width}"
          RelativeLayout.HeightConstraint= "{ConstraintExpression Type=RelativeToParent, Property=Height}" />
      <AbsoluteLayout x:Name="AbsoluteLayout"
                      RelativeLayout.WidthConstraint= "{ConstraintExpression Type=RelativeToParent, Property=Width}"
                      RelativeLayout.HeightConstraint= "{ConstraintExpression Type=RelativeToParent, Property=Height}">
          <StackLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Orientation="Vertical" AbsoluteLayout.LayoutBounds="0, 0, 1, 1"
                       AbsoluteLayout.LayoutFlags="All">
              <forms:CommonHeader x:Name="CommonHeader" />
              <StackLayout BackgroundColor="Red" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
                  <forms1:AnimationView 
                      x:Name="AnimationView" 
                      Animation="video_cam.json" 
                      AutoPlay="True" Loop="true"
                      VerticalOptions="FillAndExpand"
                      HorizontalOptions="FillAndExpand" />
              </StackLayout>

Same code but android works/shows the animation the other doesn't? No idea whats causing this for iOS i have called AnimationViewRenderer.Init(); in iOS project and the correct .json in the iOS project.

I am using latest Xamarin.forms 2.4.0.282

Not able to make running animations

I am having difficulty getting this and several other AE exports working.
Extra compositions also don't display, and it is quite a headache, even if they are being delayered very carefully.

This one was made very carefully and simply, yet it doesn't do it.

Any ideas?

FallingBallTest.zip

When I try to add Com.Airbnb.Xamarin.Lottie to my PCL

I have Xamarin.Forms added already. Not sure why its complaining?

Installing Com.Airbnb.Xamarin.Forms.Lottie 1.0.0.5.
Install failed. Rolling back...
Package 'Com.Airbnb.Xamarin.Forms.Lottie.1.0.0.5 : Xamarin.Forms [2.3.3.180, )' does not exist in project 'oneiota'
Package 'Com.Airbnb.Xamarin.Forms.Lottie.1.0.0.5 : Xamarin.Forms [2.3.3.180, )' does not exist in folder 'C:\Users\ryan\Dropbox\Programming\oneiota\packages'
Could not install package 'Com.Airbnb.Xamarin.Forms.Lottie 1.0.0.5'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile259', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

Only Partial Animation is Showing

I attempted to load the example Pink Drink Machine from the Lottie Files website. The animation works! It looks super cool. The only problem is it only renders part of the image. If you compare the bolts and the plunger in the canister, they do not even show up. It's like pieces of the animation are missing.

This is my Xamarin Forms code:

public partial class AnimationDemoAppPage : ContentPage
    {
        public AnimationDemoAppPage()
        {
            InitializeComponent();

            var animationView = new AnimationView()
            {
                Animation = "pink_drink_machine.json",
                Loop = true,
                AutoPlay = true,
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor = Color.Yellow
            };

            Content = animationView;
        }
    }

And this is the resulting image on the iOS simulator. I also tried it on a real device. I also tried a different lottie file altogether and get the same result. I only added the yellow background to see if it made a difference in the bolts showing up. Any ideas on why the animation is only partially showing up?

Animations doesnยดt run

Hi, I am trying to run my animation in xamarin forms but doesnยดt work, put If I change the animation for one of the page provides like LottieLogo1.json works normally. I am using the same code I only change the name of de file. Some can help me.

Icono-Gira.zip

AE expressions support

Support of AE expressions would be helpful for many reasons, like a progress rings and other. Lottie supports it feature now.

LottieAnimationView not displayed because it is too large to fit into a software layer

When I run Example.Forms.Droid project on my Samsung S6 edge I get the following log:

[View] LottieAnimationView not displayed because it is too large to fit into a software layer (or drawing cache), needs 15367680 bytes, only 14745600 available

This happens when using LottieLogo1.json, but not when using Belo Foggy.json.

I don't have this problem when I run Example.Droid project using this fragment_list.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="32dp"
        android:background="@color/colorPrimary">
        <com.airbnb.lottie.LottieAnimationView
            android:id="@+id/animation_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            app:lottie_fileName="LottieLogo1.json"
            app:lottie_loop="true" />
    </FrameLayout>
    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layoutManager="LinearLayoutManager" />
</LinearLayout>

How can I solve this problem?

Thanks

Animation doesn't play on Xamarin.Forms iOS

Hi,
I'm new with Lottie.
I followed a couple of step-by-step to get Lottie working on Xamarin.Forms.

After running some examples successfully I wanted to add Lottie to my existing project. I did all the steps required (install NuGet's, adding json files, adding namespace on XAML ..) but when I run the app the animation doesn't run. I'm seeing a freeze finger doing nothing.

I'm trying to add that animation from lottiefiles web, which I understood needs to work in my app:
https://www.lottiefiles.com/419-like

Any tips on how can I know the detailed issue and resolve it?

Thanks in advance

Android compilation error

  • Create a new Android project
  • Add the latest stable Xamarin.Forms (2.3.3.193 now)
    • The Android support libraries are all 23.3.0
  • Add the latest Lottie forms nuget package (1.5.2.0 now)
    • Support packages get updated to 25.1.1
  • Build

Getting

java.lang.IllegalArgumentException: already added :  Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat;

You must set an images folder Exception

` java.lang.IllegalStateException: You must set an images folder before loading an image. Set it with LottieComposition#setImagesFolder or LottieDrawable#setImagesFolder

08-21 12:45:44.562 E/AndroidRuntime( 9788): at com.airbnb.lottie.ImageAssetManager.bitmapForId(ImageAssetManager.java:73)

08-21 12:45:44.562 E/AndroidRuntime( 9788): at com.airbnb.lottie.LottieDrawable.getImageAsset(LottieDrawable.java:537)
...`

Hi - i keep getting the above error and i can't seem to find how to set the images folder. Is there a way programatically or in the JSON ?

Below is a portion of my JSON. Trying to run a forms page on an Android device API24

{ "v": "4.10.1", "fr": 15, "ip": 0, "op": 59, "w": 768, "h": 458, "nm": "Splashscreen", "ddd": 0, "assets": [ { "id": "image_0", "w": 1191, "h": 842, "u": "images/", "p": "img_0.png" }, ....

Thanks

Binding to iOS

I'm pretty sure I discovered why my iOS project wasn't rendering but my Android was.

My Animation in the XAML was set as a Binding (See Below). Once I changed it to the filename vs. setting it after it seems to work. I had to remove the Xamarin.Forms.iOS nuget and copy and paste the Renderers for the platform. But now its working.

<customRenderer:AnimationViewLottie VerticalOptions="StartAndExpand" HorizontalOptions="CenterAndExpand" x:Name="animationView" Animation="{Binding AnimationResource}" BackgroundColor="Transparent" WidthRequest="200" HeightRequest="200" Loop="True" AutoPlay="True"/>

TimeSpan does not accept floating point Not-a-Number values.

After updating packages to the latest versions:
com.airbnb.ios.lottie - 2.0.3.1
com.airbnb.xamarin.forms.lottie - 2.3.1

The app crashes with TimeSpan does not accept floating point Not-a-Number values. error message.

Is it something known?

<forms:AnimationView x:Name="AnimationView" Animation="LottieLogo1.json" Loop="false" AutoPlay="false" Grid.Row="3" Grid.ColumnSpan="2" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" />

at System.TimeSpan.Interval (System.Double value, System.Int32 scale) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/timespan.cs:230
at System.TimeSpan.FromMilliseconds (System.Double value) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/timespan.cs:240
at Lottie.Forms.iOS.Renderers.AnimationViewRenderer.OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs1[TElement] e) [0x000c3] in /Users/martijnvandijk/Documents/LottieXamarin/Lottie.Forms.iOS/Renderers/AnimationViewRenderer.cs:53 at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].SetElement (TElement element) [0x00110] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:167
at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:116 at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x0001b] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Platform.cs:192 at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x00009] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:63 at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:36 at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].SetElement (TElement element) [0x000cc] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:155
at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:116 at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x0001b] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Platform.cs:192 at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x00009] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:63 at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:36 at Xamarin.Forms.Platform.iOS.PageRenderer.ViewDidLoad () [0x00086] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:105 at (wrapper managed-to-native) ObjCRuntime.Messaging:IntPtr_objc_msgSendSuper (intptr,intptr) at UIKit.UIViewController.get_View () [0x00030] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/build/ios/native/UIKit/UIViewController.g.cs:2718 at Xamarin.Forms.Platform.iOS.PageRenderer.get_NativeView () [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:40 at XFGloss.iOS.Renderers.XFGlossContentPageRenderer.CanUpdate (System.String propertyName) [0x00000] in <eb71ba07dbbc4ee9bd122203c0336d84>:0 at XFGloss.Gradient.UpdateProperties (System.String glossPropertyName, XFGloss.IGradientRenderer renderer, System.String elementPropertyChangedName) [0x00000] in <9f1677629a2543bca47d9726279dad2d>:0 at XFGloss.XFGlossElement1[TXFGlossRenderer].AttachRenderer (System.String glossPropertyName, TXFGlossRenderer renderer) [0x0005e] in <9f1677629a2543bca47d9726279dad2d>:0
at XFGloss.iOS.Renderers.XFGlossContentPageRenderer.OnElementChanged (Xamarin.Forms.Platform.iOS.VisualElementChangedEventArgs e) [0x000a4] in :0
at Xamarin.Forms.Platform.iOS.PageRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00014] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:49
at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x0001b] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Platform.cs:192
at Xamarin.Forms.Platform.iOS.NavigationRenderer.CreateViewControllerForPage (Xamarin.Forms.Page page) [0x00021] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:340
at Xamarin.Forms.Platform.iOS.NavigationRenderer+d__44.MoveNext () [0x0000a] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:327
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357
at Xamarin.Forms.Platform.iOS.NavigationRenderer+<b__39_0>d.MoveNext () [0x00022] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:214
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__6_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1018
at UIKit.UIKitSynchronizationContext+c__AnonStorey0.<>m__0 () [0x00000] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/UIKit/UIKitSynchronizationContext.cs:24
at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/Foundation/NSAction.cs:163
--- End of stack trace from previous location where exception was thrown ---
at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/UIKit/UIApplication.cs:63
at ..Application.Main (System.String[] args) [0x00001] in .../iOS/Main.cs:17

Xamarin.Forms issue

Hi,
the library seems great, but I have some initial problems :-( I installed NuGet packages into PCL and Droid projects, put sample LottieLogo1.json file inside Asset directory (Droid version), place sample XAML code into PCL:

xmlns:forms="clr-namespace:Lottie.Forms;assembly=Lottie.Forms"
...
  <forms:AnimationView 
    x:Name="AnimationView"
    Animation="LottieLogo1.json"
    Loop="True"
    AutoPlay="True"
    VerticalOptions="FillAndExpand"
    HorizontalOptions="FillAndExpand" />

But when opening the page, the following error message is shown:

System.TypeLoadException: Could not load type 'Lottie.Forms.Droid.AnimationViewRenderer' from assembly 'Lottie.Forms.Droid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

Any idea how fix that and why is it happening?

thanks!
Pavel

Clickable AnimationView in Xamarin Forms

Are there any plans to add a Command property to the AnimationView or make GestureRecognizers to work with the AnimationView?

// This does not work
AnimationView.GestureRecognizers.Add(new TapGestureRecognizer()
{
    Command = new Command(() => {
         var i = 42;  
    })
});

I'm interested in implementing either the Command property and/or fix the GestureRecognizer bug (if it is a bug).

Can't run sample on iOS device

Hi there!

This project looks wonderful. I managed to run it on a simulator but the app crashes on my device (iPhone 7 iOS 10.2). I have the following exception :

System.ExecutionEngineException: Attempting to JIT compile method 'Airbnb.Lottie.LAAnimationView:.ctor (Foundation.NSUrl)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.

The exception happens here:

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var lottieView = new LAAnimationView(NSUrl.FromString("https://raw.githubusercontent.com/airbnb/lottie-ios/master/Example/Assets/LottieLogo1.json")); // <--- Exception here
            [...]
        }

Trouble with simple text?

First off, just wanted to say what a great job you have done on this wonderful plugin!

I am working on a proof-of-concept for a client and decided to incorporate some AE Animation effects into the project.

For some odd reason, I'm seeing a weird issue with my text whereby any letters that should be rendered with transparency are in fact filled (such as "o" for example).

I'm attaching a sample JSON file along with the image of the issue happening on the iOS Simulator (have not tested on Android as yet)

Sample JSON
Simulator Screenshot

As far as I can surmise, it looks like an issue with the Merge Path that AE creates in order to produce the cutout area of letters/numbers with holes in them. How can I rectify this?

Any help would be greatly appreciated!

R

Edit: Just tried the previewing the JSON file in LottiePreview @ LottieFiles and it seems to display correctly without issue.

Problem when adding Com.Airbnb.Xamarin.Forms.Lottie in iOS project

In a Xamarin.Forms project when I add the lib Com.Airbnb.Xamarin.Forms.Lottie, in iOS project, the following problem occurs:

/Users/homerokzam/Projects/Lottie/iOS/MTOUCH: Error MT0023: The root assembly /Users/homerokzam/Projects/Lottie/iOS/bin/iPhoneSimulator/Debug/Lottie.iOS.exe conflicts with another assembly (/Users/homerokzam/Projects/Lottie/packages/Com.Airbnb.iOS.Lottie.1.5.1.1/lib/xamarinios/Lottie.iOS.dll). (MT0023) (Lottie.iOS)

Plans for Forms.UWP support?

My team is excited about this project. Are there plans to support Forms.UWP? Has any work been done toward that goal?

Tap and play on Xamarin forms

I add Gesture Recognizer on AnimationView and i call Play() here but nothing happened. Any help ?

		var tapGestureRecognizer = new TapGestureRecognizer() { NumberOfTapsRequired = 1 };
		tapGestureRecognizer.Tapped += (s, e) =>
		{
			AnimationView.Play();
		};
		AnimationView.GestureRecognizers.Add(tapGestureRecognizer);

iOS not Animating

After removing 1.05 and my custom renders and upgrading to Xamarin.Forms version because the PCL issue got fixed, my iOS isn't animating but Android is working perfectly!

Just letting ya'll know.

Unable to link properly on iOS

I'm using Xamarin Forms and integrated Lottie. It works wonderfully on the simulator / my devices, however, I can't generate an IPA:

2> error: Invalid bitcode signature
2> clang: error: linker command failed with exit code 1 (use -v to see invocation)
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(747,3): error : Native linking error: error: Invalid bitcode signature
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(747,3): error : Native linking failed. Please review the build log.

Removing your package solved the issue.

iOS Simulator

Is Lottie supposed to work in the ios simulator?
I have a XAML parse exception on the page containing the animation.
I've linked nuggets com.airbnb.xamarin.forms.lottie on both my pcl and ios projects
and com.airbnb.ios.lottie on ios project.

Thanks for you help and this great lib

Repeater and shape merge/subtract are not working

Hi there.

I found that a particular test I created didn't work fully, although it still displayed and animated, which was something. The trashcan lid handle had a subtract, but it didn't work, and the central bars on the trashcan had a x3 repeater, but only the original bar on the left displayed.

Repeater is a luxury (though it would be nice), but if the subtract could be used, that would be a very important step forward. Or does it already work, and I am doing something wrong?

Included is the original AE file, as well as the exported .json file.

Is there any way to verify that an exported .json will not conflict with the current state of the art with Lottie? Its very hit and miss, and its hard to learn, because there is no indicator about why a certain animation completely fails to display.

Thank you for the hard work, and best regards.

trashcan.zip

trashcan - simulator
trashcan - ae

Error inflating class android.support.v7.widget.Toolbar

Error: Android.Views.InflateException: Binary XML file line #1: Error inflating class android.support.v7.widget.Toolbar.

I Find a Solution:

The created app used xamarin.forms version 2.3.3.180.
After changing this to xamarin.forms version 2.3.3.175, the error was gone.

PS: THis is a Tips

iOS: LOTAnimationView.AnimationDuration always returns 0

I just updated from 1.0.0.7 to 2.0.3.0 and I noticed that LOTAnimationView.AnimationDuration always returns 0, this wasn't the case in version 1.0.0.7. A workaround is to use LOTAnimationView.SceneModel.TimeDuration instead. Is this intentionally?

.Progress is improperly bound?

I have an animation (favorite) where the "beginning" is an empty star, and the end is a "full" star. This works fine going forward, but doesn't allow a return to the origin of the animation. This seems to be because there is a one-way bound property.

Expected behavior:
Any time the .Progress property is set the animation should jump to that position in the animation

Observed behavior:
If the same .Progress value is set twice, the second time it is ignored. This isn't a problem except that the progress can be progressed through "Playing" the animation, but this doesn't appear to update the value read from .Progress

Workarounds:
Before setting to the desired progress set to a different nearby progress (e.g. 0.01f 0.0f

Simple example to reproduce (Xamarin forms):

.xaml

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage 
    xmlns="http://xamarin.com/schemas/2014/forms" 
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
    xmlns:forms="clr-namespace:Lottie.Forms;assembly=Lottie.Forms"
    x:Class="Mobil.Tommeplan.Core.Pages.LottiePage">
	<ContentPage.Content>
 <StackLayout Orientation="Horizontal" BackgroundColor="Blue" HorizontalOptions="FillAndExpand">
                <forms:AnimationView
                    x:Name="FavoriteAnimation"
                    Animation="favorite.json"
                    Loop="false" Scale="2" 
                    VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"/>
                <ContentView WidthRequest="10"/>
                <Button Clicked="Handle_Clicked" BackgroundColor="Green"/>
                <Button Clicked="Handle_Clickedd" BackgroundColor="Red" />
            </StackLayout>
	</ContentPage.Content>
</ContentPage>

.xaml.cs:

using System;
using System.Collections.Generic;

using Xamarin.Forms;

namespace Mobil.Sample.Core.Pages
{
    public partial class LottiePage : ContentPage
    {
        public AddPropertyPage()
        {
            InitializeComponent();
        }

		void Handle_Clicked(object sender, System.EventArgs e)
		{
			FavoriteAnimation.Play();
		}

		void Handle_Clickedd(object sender, System.EventArgs e)
		{
			// remove one of these lines to see the error
			FavoriteAnimation.Progress = 0.01f;
			FavoriteAnimation.Progress = 0.00f;
		}
    }
}

How could we merge code together?

Hi @martijn00,

I have also created Xam Binding for Lottie. I also migrated fully sample for the iOS part.

I see your code has a lot of things for binding, not that the generated one. It's like craftsmanship.

It would be great if we could merge our code together and together maintain a single code base.

Regards,
Tuyen.

crash on ios in [LOTBezierPath dealloc]

Hi, in our Xamarin project we have integrated LottieXamarin to get nice animations, and its working great, except for occasional crashes on iOS devices. It has a low occurence, but can be repeated on sereral iOS models and OS versions.
Here is the stacktrace i get on the iOS simulator, (Visual studio can't catch it on device).

Native stacktrace:
2017-10-06 16:18:53.831 PoleEmploi.Recherche.iOS[7736:241199] critical: 	0   PoleEmploi.Recherche.iOS            0x0000000105d18a04 mono_handle_native_crash + 244
2017-10-06 16:18:53.832 PoleEmploi.Recherche.iOS[7736:241199] critical: 	1   PoleEmploi.Recherche.iOS            0x0000000105d261fe mono_sigill_signal_handler + 46
2017-10-06 16:18:53.832 PoleEmploi.Recherche.iOS[7736:241199] critical: 	2   JavaScriptCore                      0x0000000110a3ff63 _ZN3WTFL16jscSignalHandlerEiP9__siginfoPv + 563
2017-10-06 16:18:53.832 PoleEmploi.Recherche.iOS[7736:241199] critical: 	3   libsystem_platform.dylib            0x00000001162f3b3a _sigtramp + 26
2017-10-06 16:18:53.832 PoleEmploi.Recherche.iOS[7736:241199] critical: 	4   ???                                 0x0000000100000000 0x0 + 4294967296
2017-10-06 16:18:53.832 PoleEmploi.Recherche.iOS[7736:241199] critical: 	5   PoleEmploi.Recherche.iOS            0x0000000105b269e5 -[LOTBezierPath dealloc] + 46
2017-10-06 16:18:53.832 PoleEmploi.Recherche.iOS[7736:241199] critical: 	6   libobjc.A.dylib                     0x00000001151bca2e _ZN11objc_object17sidetable_releaseEb + 202
2017-10-06 16:18:53.832 PoleEmploi.Recherche.iOS[7736:241199] critical: 	7   PoleEmploi.Recherche.iOS            0x0000000105b35e5c -[LOTRenderGroup performLocalUpdate] + 392
2017-10-06 16:18:53.832 PoleEmploi.Recherche.iOS[7736:241199] critical: 	8   PoleEmploi.Recherche.iOS            0x0000000105b24b44 -[LOTAnimatorNode updateWithFrame:withModifierBlock:forceLocalUpdate:] + 247
2017-10-06 16:18:53.833 PoleEmploi.Recherche.iOS[7736:241199] critical: 	9   PoleEmploi.Recherche.iOS            0x0000000105b35cac -[LOTRenderGroup updateWithFrame:withModifierBlock:forceLocalUpdate:] + 163
2017-10-06 16:18:53.833 PoleEmploi.Recherche.iOS[7736:241199] critical: 	10  PoleEmploi.Recherche.iOS            0x0000000105b35c70 -[LOTRenderGroup updateWithFrame:withModifierBlock:forceLocalUpdate:] + 103
2017-10-06 16:18:53.833 PoleEmploi.Recherche.iOS[7736:241199] critical: 	11  PoleEmploi.Recherche.iOS            0x0000000105b30986 -[LOTLayerContainer displayWithFrame:forceUpdate:] + 550
2017-10-06 16:18:53.833 PoleEmploi.Recherche.iOS[7736:241199] critical: 	12  PoleEmploi.Recherche.iOS            0x0000000105b297ac -[LOTCompositionContainer displayWithFrame:forceUpdate:] + 381
2017-10-06 16:18:53.833 PoleEmploi.Recherche.iOS[7736:241199] critical: 	13  PoleEmploi.Recherche.iOS            0x0000000105b30729 -[LOTLayerContainer display] + 216
2017-10-06 16:18:53.833 PoleEmploi.Recherche.iOS[7736:241199] critical: 	14  QuartzCore                          0x000000010d8802ef _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 655
2017-10-06 16:18:53.833 PoleEmploi.Recherche.iOS[7736:241199] critical: 	15  QuartzCore                          0x000000010d8abae4 _ZN2CA11Transaction6commitEv + 500
2017-10-06 16:18:53.834 PoleEmploi.Recherche.iOS[7736:241199] critical: 	16  QuartzCore                          0x000000010d8ac830 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 76
2017-10-06 16:18:53.834 PoleEmploi.Recherche.iOS[7736:241199] critical: 	17  CoreFoundation                      0x000000011427bdb7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
2017-10-06 16:18:53.834 PoleEmploi.Recherche.iOS[7736:241199] critical: 	18  CoreFoundation                      0x000000011427bd0e __CFRunLoopDoObservers + 430
2017-10-06 16:18:53.834 PoleEmploi.Recherche.iOS[7736:241199] critical: 	19  CoreFoundation                      0x0000000114260324 __CFRunLoopRun + 1572
2017-10-06 16:18:53.834 PoleEmploi.Recherche.iOS[7736:241199] critical: 	20  CoreFoundation                      0x000000011425fa89 CFRunLoopRunSpecific + 409
2017-10-06 16:18:53.834 PoleEmploi.Recherche.iOS[7736:241199] critical: 	21  GraphicsServices                    0x000000011686e9c6 GSEventRunModal + 62
2017-10-06 16:18:53.834 PoleEmploi.Recherche.iOS[7736:241199] critical: 	22  UIKit                               0x0000000107c55d30 UIApplicationMain + 159
2017-10-06 16:18:53.834 PoleEmploi.Recherche.iOS[7736:241199] critical: 	23  ???                                 0x0000000133b04264 0x0 + 5162156644
2017-10-06 16:18:53.834 PoleEmploi.Recherche.iOS[7736:241199] critical: 	24  ???                                 0x0000000133b03e9d 0x0 + 5162155677

Blank View / Animation is not playing

Hi all,
can you tell me why this code is not working?
My project created using XAMARIN.FORMS

I used animation file: lottielogo1.json
This file added to all 3 projects :
(Portable)/resources/lottielogo1.json
(Droid)/Assets/lottielogo1.json
(iOS)/Resources/lottielogo1.json

Code from (Portable) project:

public partial class PageIntro : ContentPage
    {
        public PageIntro()
        {
            InitializeComponent();

            // CREATE ANIMATION LOTTIE VIEW
            AnimationView animation = new Lottie.Forms.AnimationView()
            {
                // Initial parameters
                Animation = "lottielogo1.json",
                Loop = true,
                AutoPlay = true,
                WidthRequest = 400,
                HeightRequest = 400,
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            // START PLAYING
            animation.IsEnabled = true;
            animation.IsVisible = true;
            animation.Play();

            // ADDING ANIMATION TO THE VIEW
            CONTENT_LOCAL.Children.Add(animation);

            // CHECKING BY TAP : Playing or not
            var tap = new TapGestureRecognizer
            {
                Command = new Command(() =>
                {
                    if (animation.IsPlaying)
                    {
                        DisplayAlert("Animation", "is Playing : Progress is " + animation.Progress, "Close");

                    }
                    else
                    {
                        DisplayAlert("Animation", "is NOT Playing", "Close");
                    }
                } ),
                NumberOfTapsRequired = 1
            };
            animation.GestureRecognizers.Add(tap);
        }

So as result there is nothing happens.
I tested on Android and iOS. Just blank screen.
By TAPing , I'm getting IS NOT PLAYING message.
Can you please advice what do I miss in that code.
Thank you.

Support for macOS

README does not say anything about the support for macOS and TvOS.

  1. If the library supports macOS and TvOS, then what is the minimum version that is supported?
  2. There are no examples on the usage of the library in macOS/TvOS apps.

I believe README should be updated accordingly.

Animation working great on preview, but totally broken on mobile. Help!

Hi

I've created a pretty basic animation which is to be used as an onboarding screen for iOS and Android using Xamarin. It works fine when I throw the .json file into the lottie files preview - https://www.lottiefiles.com/share/5uJU9w

But when viewing it on mobile (at least the simulator) it is really broken. I've gone through the file and cleaned up every layer, but still it's the same problem.

It looks like the attached!:
screen shot 2017-10-04 at 13 56 28

Attached is the .aep file.

Can anyone offer any suggestions as to why this might be happening? I thought it might be the semi-transparent, blurred overlay that was causing problems, but even with that swapped for an image, or removed entirely, it's the same problem.

overdraft-onboarding.aep.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.