如何使用 Android 支持库 23.2 将 vectorDrawable 用作推送通知的图标? setSmallIcon 给出错误

How can I use vectorDrawable as icon for push notifications using Android Support Library 23.2? setSmallIcon gives error

我的应用程序在 API < v21 下,所以我使用 Android 支持库 23.2 来管理我的 vectorDrawables。

 android {  
   defaultConfig {  
     vectorDrawables.useSupportLibrary = true  
    }  
 }

除推送通知图标外,所有视图均正常:

NotificationCompat.Builder mBuilder =
                new NotificationCompat.Builder(this)
                        .setColor(getResources().getColor(R.color.colorAccent))
                        .setSmallIcon(R.drawable.ic_play_arrow_white_24dp) //ERROR
                        .setContentTitle(getString(R.string.app_name))
                        .setContentText(getString(R.string.playing));

我遇到了错误:

    E/AndroidRuntime: FATAL EXCEPTION: main
android.app.RemoteServiceException: Bad notification posted from package com.ashomok.lullabies: Couldn't create icon: StatusBarIcon(pkg=com.ashomok.lullabiesuser=0 id=0x7f020053 level=0 visible=true num=0 )
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1401)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)

在这种情况下如何使用 vectorDrawable?有可能吗?

不,VectorDrawables 只能在 Android 5.0+ 设备上发送到您的应用之外 - 在此之前,框架不知道如何处理矢量可绘制对象。