Android NotificationManager giving me “no valid small icon” error

前端 未结 4 1781
悲&欢浪女
悲&欢浪女 2020-12-30 20:14

I am having a strange error with notification manager.

@Override
public void onMessageReceived(String from, Bundle data)
{
     Log.i(TAG, \"IP : \" + (Strin         


        
4条回答
  •  囚心锁ツ
    2020-12-30 20:34

    This suddenly started happening to my application. After some research, I found this change in my manifest file actually started causing it.

    from:

      
    

    to:

      
    

    I saw somewhere that somebody noted that it only checks for the icon if the target sdk version is set. Sure enough, in the source, there is this :

    if (mContext.getApplicationInfo().targetSdkVersion > Build.VERSION_CODES.LOLLIPOP_MR1) {
        if (notification.getSmallIcon() == null) {
            throw new IllegalArgumentException("Invalid notification (no valid small icon): "
                    + notification);
        }
    }
    

    Luckily, the solution was simple, just define the icon in the manifest:

      
    

提交回复
热议问题