Hi I can't inject the RestService anywhere in my code. I'm working test driven so I am using Robolectric to test this code. I hope it isn't a problem with AA+Robolectric, I don't have any experience with this. The weird thing is that in my tests I can manually insert the generated RestClient_, but it doesn't get inserted automatically. So I can do this:
RestClient rest = new RestClient_(activity.getApplicationContext());
but the following doesn't work:
@RestService
RestClient restClient;
I get a NullPointerException on restClient.
I also didn't forget the @EBean tag
@EBean
public class Player {
@RestService
RestClient restClient;
private int playerId;
public Player() {
}
public int getPlayerId() {
return playerId;
}
public List<Card> getHand() {
return restClient.getHand(playerId);
}
}
In the log I can see that Android Annotations has processed everything correctly.
This is my first project with Android Annotations and I can't grasp why the dependency injection doesn't work. No dependency injection removes almost all the benefit of using Android Annotations. Thanks in advance!
Some extra information: I am instantiating my Player object in an Android Annotations-annotated REST Service. A code snippet of the method creating the Player object.
@Get(value = "/players/createAnonymous")
@Accept(MediaType.APPLICATION_JSON)
public Player createAnonymousPlayer();