5

I have an application that loads users installed applications and shows the list inside recyclerview (App name & icon). This exception is thrown on android 8+ devices and also not on all device models (mostly on Samsung and Huawei devices)

View.java line 19595
android.view.View.getDrawableRenderNode

Fatal Exception: java.lang.NullPointerException
Attempt to invoke virtual method 'boolean android.graphics.drawable.Drawable.isProjected()' on a null object reference
android.graphics.drawable.AdaptiveIconDrawable.isProjected + 551 (AdaptiveIconDrawable.java:551)
android.view.View.getDrawableRenderNode + 19595 (View.java:19595)
android.view.View.drawBackground + 19524 (View.java:19524)
com.android.internal.os.ZygoteInit.main + 857 (ZygoteInit.java:857)

Its the exception log from fabric. Any help would be appreciated.

RKRK
  • 1,284
  • 5
  • 14
  • 17
Reza
  • 730
  • 2
  • 11
  • 25
  • how are you getting the image and setting it to the view? – Antonio Jun 29 '19 at 13:59
  • @Antonio imageView.setImageDrawable(applicationInfo.loadIcon(context.getPackageManager())); – Reza Jul 05 '19 at 15:42
  • This is related to https://stackoverflow.com/questions/52132029/exception-at-android-graphics-drawable-adaptiveicondrawable-isprojected-in-andr?noredirect=1&lq=1. As per the link https://stackoverflow.com/questions/44447056/convert-adaptiveicondrawable-to-bitmap-in-android-o-preview that OP posted in the comments, the solution he found was to convert the `AdaptiveIconDrawable` to `Bitmap` which you can then use to create a `BitmapDrawable` if you wish to have `Drawable` objects. – chjarder Aug 14 '19 at 06:17

2 Answers2

4

I was getting the same error and I found that removing <item android:drawable="?attr/selectableItemBackground" /> solved the issue.

mayank1513
  • 8,767
  • 6
  • 37
  • 99
-1

You can try to do like this imageview.setImageResource(resID). I tried this and it is working.