Closed SalmanTKhan closed 7 years ago
Can I see the stacktrace?
I apologize, i'm not proficient with gradle to get the stacktrace out of android studio. I presume my error is that we have a case not handled by ribbonizer plugin because my if statement makes it return null when the build type isn't named alpha. So is there a return no filter function?
ribbonizer {
// "manifest application[android:icon]" is automatically added to the list
iconNames "@drawable/ic_notification", "@drawable/widget_preview"
builder { variant, iconFile ->
// change ribbon colors by product flavors
if (variant.buildType.name == "alpha") {
if (variant.flavorName == "local") {
return grayRibbonFilter(variant, iconFile)
} else if (variant.flavorName == "staging") {
return yellowRibbonFilter(variant, iconFile)
} else {
return greenRibbonFilter(variant, iconFile)
}
}
}
}
java.lang.NullPointerException (no error message)
Looks like we just need a null check here in order to support this. I'll see if I can a pull request through.
Stacktrace:
Caused by: java.lang.NullPointerException
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)
at com.github.gfx.ribbonizer.plugin.Ribbonizer$process.call(Unknown Source)
at com.github.gfx.ribbonizer.plugin.RibbonizerTask$_run_closure1$_closure6$_closure7.doCall(RibbonizerTask.groovy:66)
at com.sun.proxy.$Proxy79.accept(Unknown Source)
at com.github.gfx.ribbonizer.plugin.RibbonizerTask$_run_closure1$_closure6.doCall(RibbonizerTask.groovy:55)
at com.sun.proxy.$Proxy79.accept(Unknown Source)
at com.github.gfx.ribbonizer.plugin.RibbonizerTask$_run_closure1.doCall(RibbonizerTask.groovy:52)
at com.sun.proxy.$Proxy79.accept(Unknown Source)
at com.github.gfx.ribbonizer.plugin.RibbonizerTask.run(RibbonizerTask.groovy:41)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:228)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:621)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:604)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
... 68 more
In the mean time, I found a workaround! Just return a custom Consumer object that does nothing.
class NoopFilter implements java.util.function.Consumer {
@Override
void accept(Object o) {
}
}
ribbonizer {
builder { variant, iconFile ->
if (variant.buildType.name == "alpha") {
// [...]
}
else {
return new NoopFilter()
}
}
}
Remove ribbons from certain builds, I want to Ribbonize my Alpha builds only, using the custom as an example I tried just adding an if statement checking for variant.buildType.name == alpha which worked fine but when I built the production debug build it would give me a null pointer exception for ribbonizer. Is there no way to disable ribbonizer for certain builds?