What I did:
Step 1)
Added the following dependency in graddle:
compile 'com.airbnb.android:lottie:2.0.0-beta4'
Step 2)
Airbnb do not tell us where to place the animated JSON files. Instead, I've seen it in their sample apps that it is placed on app/src/main/assets. So I created that folder and inserted some JSON animations there.
Step 3)
Added the following on activity_main.xml:
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/animation_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:lottie_fileName="EmptyState.json"
app:lottie_loop="true"
app:lottie_autoPlay="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Upon running the app I get the following error:
04-29 12:55:37.253 21877-21877/com.example.ross.testitout E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.ross.testitout, PID: 21877
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ross.testitout/com.example.ross.testitout.MainActivity}: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class com.airbnb.lottie.LottieAnimationView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
Wondering what I'm doing wrong. There's also a lack of thorough tutorials, which is a shame, a beginner like me needs to spend way longer than necessary to figure things out.
Thanks.
To answer my own question, the problem is the lack of the official assets folder. You can create it manually, but it ain't going to work.
To make it work do the following:
Open your project in Android Studio.
Select anything on your project folders located on the left hand side.
Press alt+insert, a menu will popup.
Select the sub-menu "Folder", and then click on "Assets Folder".
This will create the assets folder you need to store your animations.
From there on you can insert the JSON animations and link it there.
You can get the animations from various places (like lottie files or official sample app) or make them yourself using Adobe After Effects.