Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude XML Resources from being processed by RibbonizerTask #19

Merged
merged 2 commits into from
Jul 18, 2017

Conversation

mannodermaus
Copy link
Contributor

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
Copy link
Member

gfx commented Jul 18, 2017

Nice catch. Thanks.

@gfx gfx merged commit 81ffe3f into maskarade:master Jul 18, 2017
@gfx
Copy link
Member

gfx commented Jul 21, 2017

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

@lksnmnn
Copy link

lksnmnn commented Jun 20, 2019

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

#31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants