maskarade / gradle-android-ribbonizer-plugin

Modifies launcher icons on debug build
https://bintray.com/gfx/maven/ribbonizer-plugin
MIT License
355 stars 38 forks source link

Exclude XML Resources from being processed by RibbonizerTask #19

Closed mannodermaus closed 7 years ago

mannodermaus commented 7 years ago

Right now, RibbonizerTask fails with an NPE when trying to apply filters to a non-image resource, such as Android O's <adaptive-icon> resources:

Stack Trace ``` [ribbonizeLocalDebug] process /workspace/gradle-android-ribbonizer-plugin/example-custom/src/main/res/drawable-hdpi/ic_launcher.png [ribbonizeLocalDebug] process /workspace/gradle-android-ribbonizer-plugin/example-custom/src/main/res/drawable-mdpi/ic_launcher.png [ribbonizeLocalDebug] process /workspace/gradle-android-ribbonizer-plugin/example-custom/src/main/res/drawable-xhdpi/ic_launcher.png [ribbonizeLocalDebug] process /workspace/gradle-android-ribbonizer-plugin/example-custom/src/main/res/drawable-xxhdpi/ic_launcher.png [ribbonizeLocalDebug] process /workspace/gradle-android-ribbonizer-plugin/example-custom/src/main/res/mipmap-anydpi-v26/ic_launcher.xml :example-custom:ribbonizeLocalDebug FAILED * Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':example-custom:ribbonizeLocalDebug'. at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46) ... Caused by: java.lang.NullPointerException at com.github.gfx.ribbonizer.filter.ColorRibbonFilter.accept(ColorRibbonFilter.java:52) at com.github.gfx.ribbonizer.filter.ColorRibbonFilter.accept(ColorRibbonFilter.java:10) at com.github.gfx.ribbonizer.plugin.Ribbonizer$1.accept(Ribbonizer.java:35) at com.github.gfx.ribbonizer.plugin.Ribbonizer$1.accept(Ribbonizer.java:32) at com.github.gfx.ribbonizer.plugin.Ribbonizer.process(Ribbonizer.java:32) ... ```


Typically, this kind of "new launcher icon" is implemented inside of resource directories specific to -v26, but keeping the same name as pre-O resources. Therefore, when the launcher icon is normally named mipmap-<dpi>/ic_launcher.png, and then overridden on Android O with the adaptive icon at mipmap-anydpi-v26/ic_launcher.xml, ImageIO can't extract a BufferedImage out of that file and fails later on.

I've put a lot of thought into how Ribbonizer would be able to add ribbons to XML resources automatically, but to no avail. Ideally, that solution would also include <vector>/SVG resources.

For now, we should simply exclude XML altogether, though, in order to prevent people from using Ribbonizer after upgrading their app to Android O.

gfx commented 7 years ago

Nice catch. Thanks.

gfx commented 7 years ago

This is included in v2.0.0; synchronizing to jcenter might take a frew hours.

lksnmnn commented 5 years ago

I am getting this exact error. Without changing anything specific imho.

https://github.com/maskarade/gradle-android-ribbonizer-plugin/issues/31