Skip to content
This repository has been archived by the owner on Jan 14, 2018. It is now read-only.

Retrofit throwing exceptions for every single call #450

Open
arbitur opened this issue Jan 15, 2016 · 2 comments
Open

Retrofit throwing exceptions for every single call #450

arbitur opened this issue Jan 15, 2016 · 2 comments

Comments

@arbitur
Copy link

arbitur commented Jan 15, 2016

I use RoboSpice-Retrofit for calling my server REST api which has been working without problems until a few days ago when every single call now throws an exception, Example:

D/Retrofit: ---> HTTP GET http://192.168.0.2/test
D/Retrofit: ---> END HTTP (no body)
D/Retrofit: ---- ERROR http://192.168.0.2/test
D/Retrofit: java.lang.NoSuchMethodError: No direct method <init>(Lcom/squareup/okhttp/OkHttpClient;Lcom/squareup/okhttp/Request;ZZZLcom/squareup/okhttp/Connection;Lcom/squareup/okhttp/internal/http/RouteSelector;Lcom/squareup/okhttp/internal/http/RetryableSink;Lcom/squareup/okhttp/Response;)V in class Lcom/squareup/okhttp/internal/http/HttpEngine; or its super classes (declaration of 'com.squareup.okhttp.internal.http.HttpEngine' appears in /data/app/com.adoperator.tidyapp.customerapp-1/base.apk)
            at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.newHttpEngine(HttpURLConnectionImpl.java:362)
            at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.initHttpEngine(HttpURLConnectionImpl.java:312)
            at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:377)
            at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:497)
            at retrofit.client.UrlConnectionClient.readResponse(UrlConnectionClient.java:73)
            at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:38)
            at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:321)
            at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240)
            at java.lang.reflect.Proxy.invoke(Proxy.java:393)
            at $Proxy0.getTest(Unknown Source)
            at com.adoperator.tidyapp.rest.TestRequest.loadDataFromNetwork(TestRequest.java:18)
            at com.adoperator.tidyapp.rest.TestRequest.loadDataFromNetwork(TestRequest.java:10)
            at com.octo.android.robospice.request.CachedSpiceRequest.loadDataFromNetwork(CachedSpiceRequest.java:48)
            at com.octo.android.robospice.request.DefaultRequestRunner.processRequest(DefaultRequestRunner.java:150)
            at com.octo.android.robospice.request.DefaultRequestRunner$1.run(DefaultRequestRunner.java:217)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
            at java.lang.Thread.run(Thread.java:818)
D/Retrofit: ---- END ERROR

dependencies:

compile 'com.octo.android.robospice:robospice:1.4.14'
compile 'com.octo.android.robospice:robospice-cache:1.4.14'
compile 'com.octo.android.robospice:robospice-retrofit:1.4.14'

I suspect based on the exception that there is something wrong with the compiler, but I just tested on another computer with a fresh install of Java and Android Studio on the same project but same problems still...

This error is driving me crazy...

Anyone knows anything that could be of help? Any help is highly appreciated.

Files:

MainActivity.java:

SpiceManager spiceManager = new SpiceManager(TestAPIService.class);

protected void onStart() {
    super.onStart();

    spiceManager.start(this);

    spiceManager.execute(new TestRequest(), new RequestListener<ResponseData>() {
        ...
    });
}

TestAPIService.java:

public class TestAPIService extends RetrofitGsonSpiceService {

    @Override
    public void onCreate() {
        super.onCreate();
        addRetrofitInterface(TestAPI.class);
    }

    @Override
    protected String getServerUrl() {
        return "http://192.168.0.2";
    }
}

TestAPI.java:

public interface TestAPI {
    @GET("/test")
    ResponseData getTest();
    ...
}

TestRequest.java:

public class TestRequest extends RetrofitSpiceRequest<ResponseData, TestAPI> {

    public TestRequest() {
        super(ResponseData.class, TestAPI.class);
    }


    @Override
    public ResponseData loadDataFromNetwork() throws Exception {
        ResponseData response;

        try {
            response = getService().getTest();
        }
        catch (Exception e) {
            e.printStackTrace();
            throw e;
        }

        return response;
    }
}
@tanweijiu
Copy link

I got this error too, but i don/t know why..

@arbitur
Copy link
Author

arbitur commented Jan 27, 2016

@tanweijiu I got it solved by sacrificing 300 rep on StackOverflow: http://stackoverflow.com/questions/34809462/robospice-throwing-okhttp-exceptions

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants