【问题标题】: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);
    }
    

    【讨论】:

    • 非常感谢我无法发现我的愚蠢错误
    猜你喜欢
    • 1970-01-01
    • 2015-08-17
    • 2015-06-29
    • 1970-01-01
    • 2019-05-24
    • 2021-11-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多