¿Por qué falla mi código en las anotaciones de Android sin nada en los registros?

I'm new to android annotations so maybe I'm missing something but I'm basically trying to copy the rest client seen https://github.com/excilys/androidannotations/wiki/Rest%20API aquí

Where I have an interceptor defined as follows

@EBean(scope = Scope.Singleton)
public class RestInterceptor implements ClientHttpRequestInterceptor{

final String TAG = "rest";

AuthStore authStore;

public ClientHttpResponse intercept(HttpRequest request, byte[] data, ClientHttpRequestExecution execution)
        throws IOException{

    //Need to set the api key here but nothing happens code quits
//        Log.d("Rest",authStore.getSessionKey());

     HttpHeaders headers = request.getHeaders();


     ClientHttpResponse resp = execution.execute(request, data);

     HttpStatus code = resp.getStatusCode();


     if(code.value() == 200){
        Log.d(TAG,"success code 200"); 

         Log.d(TAG,"fail code" + code.toString());
     return resp;


But the code just quits when I try to add the extra header. The auth store class looks like this

@EBean(scope = Scope.Singleton)
 public class AuthStore {

public String apiKey,sessionKey;

public String getApiKey() {
    return apiKey;

public void setApiKey(String apiKey) {
    this.apiKey = apiKey;

public String getSessionKey() {
    return sessionKey;

public void setSessionKey(String sessionKey) {
    this.sessionKey = sessionKey;


Rest interface

@Rest(rootUrl = "https://pathtoapi/rest/public/", converters = {     GsonHttpMessageConverter.class }, interceptors = {RestInterceptor.class })
public interface ApiClient {

ApiSession forceLogin();

// if you need to add some configuration to the Spring RestTemplate.
RestTemplate getRestTemplate();

void setRestTemplate(RestTemplate restTemplate);


preguntado el 04 de septiembre de 13 a las 02:09

try catching the exception and calling e.printStackTrace() en eso. -

No exception is thrown that's why its so weird -

when you say ` just quits` what do you mean? It force closes? -

No it doesn't quit or freeze it just stops executing the code. If I comment out the header.set method it will run fine -

0 Respuestas

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.