How can I 'provide' a void method in Dagger
<p>I'm trying to migrate a project from Spring and starting to play with Dagger 2 by following a sample GitHub repo. </p>

<p>In Spring I can use an annotation at the class level to expose all of the methods of a class, including <code>void</code> methods. I want to do this in Dagger 2 i.e., I want to 'provide' a <code>void</code> method.</p>

<p>In the code example below maybe I should move the <code>printRandomUUID</code> method to the <code>Printer</code> interface. However, I'm doing this little exercise with the goal of migrating a classical Spring <code>@Component</code> or <code>@Service</code>.</p>

<p>What is the correct approach? Is it possible to provide a void method at component or module level?</p>

<pre><code>public class Main {

 interface Printer {

    void printMsg(String msg);
 }

 static class ConsolePrinter implements Printer {

    @Override
    public void printMsg(String msg) {
        System.out.println(msg);
    }
 }

 @Singleton
 @Component(modules = ConsoleModule.class)
 interface HelloWorldApp {

    Printer getPrinter();

    //this doesn't compile -&gt; java.lang.IllegalArgumentException: not a valid component method:
    void printRandomUUID();
 }

 @Module
 static class ConsoleModule {

    @Provides
    Printer providePrinter() {
        return new ConsolePrinter();
    }

    //this doesn't compile -&gt; @Provides methods must return a value (not void)
    @Provides
    void printRandomUUID() {
        System.out.println(UUID.randomUUID().toString());
    }

 }

 public static void main(String[] args) {
    HelloWorldApp app = DaggerMain_HelloWorldApp.create();
    app.getPrinter().printMsg("Hello");
    System.out.println("-");
    //app.printRandomUUID();//here i want a void method to be consumed, from the component.
 }
}
</code></pre>