WAI
Status Update
Comments
ch...@google.com <ch...@google.com> #2
What is R.drawable.notification_icon? Icons used in notifications can't be vectors before API 21.
sp...@gmail.com <sp...@gmail.com> #3
R.drawable.notification_icon is vector drawable. Sorry for misleading title and description - was using wrong words.
Before upgrade to 23.2 support library my vector drawables were rasterized automatically by Android Studio. Using vector drawable in notifations was possible then.
After upgrade to 23.2 and setting
vectorDrawables.useSupportLibrary = true
to get support-vector-drawable and srcCompat, my notifications broke.
As suggested in documentation I tried wrap my vector drawable in layer-list drawable but it did not help.
Do I need to rasterize vector drawables for notification by hand now or I can somehow get both support-vector-drawable and notification working?
Before upgrade to 23.2 support library my vector drawables were rasterized automatically by Android Studio. Using vector drawable in notifations was possible then.
After upgrade to 23.2 and setting
vectorDrawables.useSupportLibrary = true
to get support-vector-drawable and srcCompat, my notifications broke.
As suggested in documentation I tried wrap my vector drawable in layer-list drawable but it did not help.
Do I need to rasterize vector drawables for notification by hand now or I can somehow get both support-vector-drawable and notification working?
ch...@google.com <ch...@google.com> #4
Yep, that's the downside of this feature, we need to disable the automatic rasterization so that it's useful. The layer-list thing only works for things in your app. Since system ui is not in your app, it can't handle vector resources.
So basically, you need to provide a resource that the API level natively understands. There's no way for AppCompat to even help here since you give Notification a resource id for small icon, not an object.
You could keep the rasterization turned on, that way the Gradle plugin would rasterize *your* vectors. Make sure you're using 2.0.0 of the plugin though since there are bugs around this in 1.5.0.
Make sure you keep the aapt flag enabled though. Basically you *only* want the following in your build.gradle from the VDC setup:
aaptOptions {
additionalParameters "--no-version-vectors"
}
So basically, you need to provide a resource that the API level natively understands. There's no way for AppCompat to even help here since you give Notification a resource id for small icon, not an object.
You could keep the rasterization turned on, that way the Gradle plugin would rasterize *your* vectors. Make sure you're using 2.0.0 of the plugin though since there are bugs around this in 1.5.0.
Make sure you keep the aapt flag enabled though. Basically you *only* want the following in your build.gradle from the VDC setup:
aaptOptions {
additionalParameters "--no-version-vectors"
}
mo...@googlemail.com <mo...@googlemail.com> #5
Wouldn't that raster ALL vectors?
Ideally the gradle plugin would be clever and always raster only the notification/widget icons.
That's not an issue for the support library so I've created a new issue:https://code.google.com/p/android/issues/detail?id=204245
Ideally the gradle plugin would be clever and always raster only the notification/widget icons.
That's not an issue for the support library so I've created a new issue:
Description
Wrapping xml drawable in <layer-list> drawable has no effect.
Library used support-v4, appcompat-v7
Version used: 23.2
Theme used: Theme.AppCompat.Light.NoActionBar
Devices/Android versions reproduced on:
Sony Xperia Z3 Table Compact(SGP621)/Android 4.4.4
- Relevant code to trigger the issue.
//R.drawable.notification_icon - xml drawable resource
Notification notification = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.notification_icon)
.setContentTitle("Notification")
.setContentText("Text")
.build();
startForeground(NOTIFICATION_ID, notification);
FATAL EXCEPTION: main
Process: com.example:remote, PID: 11352
android.app.RemoteServiceException: Bad notification posted from package com.example: Couldn't create icon: StatusBarIcon(pkg=com.example user=0 id=0x7f020140 level=0 visible=true num=0 )
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1413)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:212)
at android.app.ActivityThread.main(ActivityThread.java:5137)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:718)
at dalvik.system.NativeStart.main(Native Method)