question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

recycleBitmaps throw NullPointerException while onDestroy after LottieAnimationView updateBitmap with a null bitmap

See original GitHub issue

LottieAnimationView throws NullPointerException while activity onDestoy. Because a bitmap in ImageAssetManager bitmaps is null. I call LottieAnimationView updateBitmap(id, null) because I need clear the bitmap, after this the exception would occur while onDestroy.

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.Bitmap.recycle()' on a null object reference at com.airbnb.lottie.manager.ImageAssetManager.recycleBitmaps(ImageAssetManager.java:96) at com.airbnb.lottie.LottieDrawable.recycleBitmaps(LottieDrawable.java:142) at com.airbnb.lottie.LottieAnimationView.recycleBitmaps(LottieAnimationView.java:277) at com.airbnb.lottie.LottieAnimationView.onDetachedFromWindow(LottieAnimationView.java:269) at android.view.View.dispatchDetachedFromWindow(View.java:15668) at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3183) at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3183) at android.view.ViewGroup.removeViewInternal(ViewGroup.java:4719) at android.view.ViewGroup.removeViewInternal(ViewGroup.java:4693) at android.view.ViewGroup.removeView(ViewGroup.java:4624) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1205) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1286) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1268) at android.support.v4.app.FragmentManagerImpl.dispatchDestroy(FragmentManager.java:2180) at android.support.v4.app.FragmentController.dispatchDestroy(FragmentController.java:271) at android.support.v4.app.FragmentActivity.onDestroy(FragmentActivity.java:386) at android.support.v7.app.AppCompatActivity.onDestroy(AppCompatActivity.java:202)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7

github_iconTop GitHub Comments

3reactions
olympikesoftcommented, Jan 9, 2018
public void recycleBitmaps() {
 Iterator<Map.Entry<String, Bitmap>> it = bitmaps.entrySet().iterator(); 
while (it.hasNext()) {
try {
 Map.Entry<String, Bitmap> entry = it.next();
 entry.getValue().recycle(); //
 if (entry.getValue() != null) 
it.remove(); 
 break;
    } catch (MyException ex) {
      log.warn("Something failed.", ex);
    }
 }
}
0reactions
gpealcommented, Nov 27, 2018

@usmanrana07 This will be resolved with #1002

Read more comments on GitHub >

github_iconTop Results From Across the Web

NullPointerException when calling Bitmap.createBitmap
The view tree is not measured, laid out and rendered until after onCreate() . ... In my case, the problem was that the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found