7

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.

Mayank Kumar Chaudhari
  • 16,027
  • 10
  • 55
  • 122
Reza
  • 906
  • 2
  • 15
  • 29
  • 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.

Mayank Kumar Chaudhari
  • 16,027
  • 10
  • 55
  • 122
0

I had the same issue with adaptive icons for the SplashScreen API on Android 8 phones. The reason was that I had only <foreground> defined in the drawable and not <background>. So you need to define both, e.g:

<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
    <foreground android:drawable="@drawable/ic_splashscreen_fg"/>
    <background android:drawable="@drawable/ic_splashscreen_bg"/>
</adaptive-icon>
4emodan
  • 955
  • 1
  • 9
  • 17