-3

I'm working with Lambda in Java and added Dagger2. However I'm having problem injecting objects to my lambda handler.

I'm getting the following error: enter image description here

Class handler.GameSessionLambda has no public zero-argument constructor: java.lang.Exception java.lang.Exception: Class handler.GameSessionLambda has no public zero-argument constructor Caused by: java.lang.NoSuchMethodException: handler.GameSessionLambda.\<init\>() at java.base/java.lang.Class.getConstructor0(Unknown Source) at java.base/java.lang.Class.getConstructor(Unknown Source)

InjectedConstants: enter image description here Module Class: enter image description here Component interface: enter image description here The Handler: enter image description here

Its working without dagger2, but since I want my handler to hold more logic and services I wanted to add dependency injection to follow best practices and save little runtime.By the way if I included an empty constructor then the lambda ignores the other constructor which results in null for the injected objects.

Raze
  • 21
  • 2

1 Answers1

1

I figured it out. The implementation of dagger is correct however Lambda requires a zero-argument constructor. So my workaround was to inject the objects directly instead of constructor injection.

Java Doc

Raze
  • 21
  • 2