Lottie-android: NullPointerException in LottieDrawable.recycleBitmaps() when set the property "android:src" for LottieAnimationView in layout.xml

Created on 12 Oct 2018  路  3Comments  路  Source: airbnb/lottie-android

Exception Message:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.airbnb.lottie.LottieDrawable.recycleBitmaps()' on a null object reference at com.airbnb.lottie.LottieAnimationView.recycleBitmaps(LottieAnimationView.java:256) at com.airbnb.lottie.LottieAnimationView.setImageDrawable(LottieAnimationView.java:176) at com.airbnb.lottie.LottieAnimationView.setImageDrawable(LottieAnimationView.java:171) at android.widget.ImageView.<init>(ImageView.java:208) at android.widget.ImageView.<init>(ImageView.java:189) at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:71) at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:67) at com.airbnb.lottie.LottieAnimationView.<init>(LottieAnimationView.java:90)

Cause:
When I set the property "android:src" for LottieAnimationView in layout.xml, because LottieAnimationView. lottieDrawable is not inited, so LottieAnimationView. lottieDrawable. recycleBitmaps() is on a null object reference.

All 3 comments

I can confirm this issue using version 2.8.0. Reverting back to 2.6.0 has solved the problem.

My XML:

android:id="@+id/loading_lottie"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:scaleType="fitCenter"
android:src="@drawable/ic_pause_s"
app:lottie_autoPlay="true"
app:lottie_fileName="loading_01.json"
app:lottie_loop="true" />

Also, by checking the source code I could see method recycleBitmaps doesn't have the 'if' preventing the error.

2.6.0:
if (lottieDrawable != null) {
lottieDrawable.recycleBitmaps();
}

2.8.0:
lottieDrawable.recycleBitmaps();

Why has this been closed?

Still a valid issue, seeing this as well

Was this page helpful?
0 / 5 - 0 ratings