hugerde
hugerde

Reputation: 949

Caused by: java.lang.NoSuchFieldError: com.squareup.okhttp.internal.http.HttpMethod.METHODS when I using retrofit

my post request 

@POST("/users/login-facebook")
@FormUrlEncoded
void loginFaceboook(@Field("token") String accessToken, @Field("fbId") String facebookId, @Field("platform") int platform,

                    Callback<LoginSignupResponse> callback)

my gradle

   compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
 compile 'com.squareup.retrofit:retrofit:1.6.1'

also my all post services have an same error

Upvotes: 2

Views: 4400

Answers (3)

Pradeep Gupta
Pradeep Gupta

Reputation: 1770

try this,

put this in gradle:

 compile 'com.squareup.retrofit:retrofit:1.6.1'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0-RC1'
compile 'com.squareup.okio:okio:1.0.0'

@FormUrlEncoded
@POST("/users/login-facebook")
void loginFaceboook(@Field("token") String accessToken, @Field("fbId") String facebookId, @Field("platform") int platform,

                    Callback<LoginSignupResponse> callback)

Upvotes: 1

laalto
laalto

Reputation: 152817

Your dependency versions are ancient and incompatible.

For retrofit 1.x the latest is 1.9.0 and with it you want to use latest okhttp 2.x which is currently 2.7.5.

Consider migrating to retrofit 2.x and okhttp 3.x though.

Upvotes: 4

Vadiraj Purohit
Vadiraj Purohit

Reputation: 938

Try below instead

compile 'com.squareup.retrofit:retrofit:1.9.0'

Also, there is no need to put entries for okhttp or okio in gradle.

Upvotes: 0

Related Questions