Answered by:
Why don't Lottie Animations work in Xamarin.Android?

Question
-
User367180 posted
In the Lottie docs, they say to use this to play your animation:
<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" />
In Android design, it says
'app' is an undeclared prefix.
Does anyone know why this is happening?
Thank you!
Tuesday, July 17, 2018 7:36 PM
Answers
-
User355640 posted
Hi @ClovyClov
As I have said, you need add the namespace, you added it at a wrong line, below is my layout:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"> <com.airbnb.lottie.LottieAnimationView android:id="@+id/animation_view" android:layout_width="wrap_content" android:layout_height="wrap_content" app:lottie_fileName="notification_bell.json" app:lottie_loop="true" app:lottie_autoPlay="true" /> </RelativeLayout>
Binary XML file line #1: Binary XML file line #1: Error inflating class com.airbnb.lottie.LottieAnimationView
Please clean and rebuild, or delete the bin and obj folder to restart your VS, it should work.
- Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
Thursday, July 19, 2018 12:49 AM
All replies
-
User355640 posted
Hi @ClovyClov
You need add namespace for 'app', read this:
You can find this:
xmlns:app="http://schemas.android.com/apk/res-auto"
Wednesday, July 18, 2018 9:10 AM -
User367180 posted
@robbit
Thank you so much for the response I GREATLY appreciate it!!! I don't know why this isn't specified anywhere on here (to my knowledge).
But this brings another issue. When I try building, I get an exception that says:
Binary XML file line #1: Binary XML file line #1: Error inflating class com.airbnb.lottie.LottieAnimationView
I've tried diagnosing why this could be happening but I honestly have no idea as there's no code used other than what it says in the docs. Any idea why this may be happening? Also attaching my xml below.
XML:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:minWidth="25px" android:minHeight="25px" android:gravity="center" android:id="@+id/linearLayout1"> <com.airbnb.lottie.LottieAnimationView android:id="@+id/animation_view" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="wrap_content" android:layout_height="wrap_content" app:lottie_fileName="cycle_animation.json" app:lottie_loop="true" app:lottie_autoPlay="true" /> <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/slideshowIV" android:src="@drawable/viewslideshow" android:scaleType="centerCrop" /> <LinearLayout android:id="@+id/idleTextLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:minWidth="25px" android:minHeight="25px" android:orientation="vertical" android:layout_weight="1" android:gravity="bottom"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center" android:gravity="center" android:orientation="vertical" android:layout_weight="3"> <ImageView android:layout_width="100dp" android:layout_height="105.2dp" android:src="@drawable/beehexagonlogo" android:layout_gravity="center" android:scaleType="fitCenter" /> <TextView android:id="@+id/loadingTxt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@android:color/white" android:text="Loading..." /> </LinearLayout> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Engage" android:fontFamily="sans-serif-light" android:textColor="@android:color/white" android:textAlignment="viewStart" android:id="@+id/textView1" android:textStyle="normal" android:textSize="36sp" android:paddingBottom="6dp" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Stay true to your brand. Engage with your customers,\non your terms, on your grounds." android:id="@+id/textView2" android:layout_below="@id/textView1" android:textColor="@android:color/white" android:lineSpacingExtra="4dp" android:textSize="12sp" /> </LinearLayout> </LinearLayout>
Wednesday, July 18, 2018 1:32 PM -
User355640 posted
Hi @ClovyClov
As I have said, you need add the namespace, you added it at a wrong line, below is my layout:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"> <com.airbnb.lottie.LottieAnimationView android:id="@+id/animation_view" android:layout_width="wrap_content" android:layout_height="wrap_content" app:lottie_fileName="notification_bell.json" app:lottie_loop="true" app:lottie_autoPlay="true" /> </RelativeLayout>
Binary XML file line #1: Binary XML file line #1: Error inflating class com.airbnb.lottie.LottieAnimationView
Please clean and rebuild, or delete the bin and obj folder to restart your VS, it should work.
- Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
Thursday, July 19, 2018 12:49 AM -
User367180 posted
Hey @robbit ,
Firstly, thanks so much for your response once again.
The code I added was AFTER me editing, but I did do it exactly as you originally said to and it gave me that Binary error for some reason. I had tried cleaning, rebuilding, restarting, and more but nothing worked.
What's even more weird is that I LITERALLY did nothing but just uncommented my code in the old file to try again and screenshot the error for you, but now it's working! This is extremely strange...
Regardless, I can't thank you enough for your help as I've been struggling with Lottie for a week, until now. Very appreciative! Have a good one!
Thursday, July 19, 2018 2:37 AM