Retrofit 2 HTTP method annotation is required (e.g., @GET, @POST, etc.)

后端 未结 4 782
耶瑟儿~
耶瑟儿~ 2021-02-04 09:01

What\'s wrong with my Retrofit configuration? I\'m having this error when I\'m adding Basic Authentication with my OkHttpClient but when I used the default client without Interc

4条回答
  •  一整个雨季
    2021-02-04 09:50

    Issue

    You're using beta2 versions of retrofit plugins which depend on beta2 version of retrofit which still lives in com.squreup.retrofit package.

    compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'
    compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
    

    Then you're importing beta3 version of retrofit itself which lives in retrofit2 package. Basically it can be used alongside beta2 version.

    compile 'com.squareup.retrofit2:retrofit:2.0.0-beta3'
    

    You're not really using beta3 at all, because it's incompatible with beta2 plugins and you'd get compile time errors. Check your imports to verify.

    What happened is (most likely) you use everything from com.square.retrofit package except for the @GET class which is from retrofit2 package. Despite their identical name these classes are not the same.

    Solution

    Move to beta4 and retrofit2 package. Fix your imports. Profit.

    compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.0.0-beta4'
    compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
    

提交回复
热议问题