【问题标题】:I could not understand way its giving error "Missing method body, or declare abstract"我无法理解它给出错误“缺少方法主体,或声明抽象”的方式
【发布时间】:2022-11-02 23:40:18
【问题描述】:
package com.example.rvj;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Url;
public class RetrofitAPI {
@GET
Call<NewsModal> getAllNews(@Url String url);
@GET
Call<NewsModal>getNewsByCategory(@Url String url);
}
应该没有错误,这个代码在其他代码中没有错误。
【问题讨论】:
标签:
android
android-studio
class
retrofit
retrofit2
【解决方案1】:
改造方法应该在一个接口中,而不是在一个类中!
试试这个:
package com.example.rvj;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Url;
public interface RetrofitAPI {
@GET
Call<NewsModal> getAllNews(@Url String url);
@GET
Call<NewsModal>getNewsByCategory(@Url String url);
}