【发布时间】:2015-10-27 12:15:45
【问题描述】:
我有这个接口:
public interface InterfazAguaHttp {
@FormUrlEncoded
@POST("/")
Call<String> saveContador(@Field("contador") Long contador, Callback<String> callBack);
}
剩下的代码是这样的:
Retrofit builder = new Retrofit.Builder()
.baseUrl(ValoresGlobales.urlServlet)
.addConverterFactory(GsonConverterFactory.create())
.build();
InterfazAguaHttp interfaz = builder.create(InterfazAguaHttp.class);
Call<String> respuesta = interfaz.saveContador(93847597L, new Callback<String>() {
@Override
public void onResponse(Response<String> response, Retrofit retrofit) {
//Some logging
}
@Override
public void onFailure(Throwable t) {
//Some logging
}
});
这一切都在一个 try-catch 块中。在捕获中,我收到此错误:
Error: No Retrofit annotation found. (parameter #2) for method InterfazAguaHttp.saveContador
我怎样才能摆脱这个错误,并且仍然有我的回调?
谢谢。
【问题讨论】:
-
将您的方法更改为
void或使用enqueue