使用Retrofit库获取动态URL的http

问题描述 投票:2回答:1

我希望通过改造获取来自网址的rss代码,如果我在获取注释中静态输入url一切正常但是使用动态网址我会收到错误。

我的界面服务:

public interface AllNewsService {

    @GET("/{newsGroup}")
    void getRss( @Path("newsGroup") String nGroup ,  Callback<AllNewsRss> callback);

}

并调用getRss方法:

  mClient.get().getRss("allnews" ,new Callback<AllNewsRss>() {
        @Override
        public void success(AllNewsRss allNewsRss, Response response) {

            Log.d(TAG,allNewsRss.getNews().get(0).getTitle());

        }

        @Override
        public void failure(RetrofitError error) {

            Log.d(TAG,error.toString());
        }
    });
}

我得到以下错误:

 retrofit.RetrofitError: AllNewsService.getRss: No Retrofit annotation found. (parameter #1)
android retrofit
1个回答
1
投票

我刚测试了你的代码,这对我有用(1.9.0)。我也没有在你的界面声明中看到任何错误。

您目前使用哪种改装版本?

你也有Proguard配置?似乎会导致Retrofit出现一些问题,这可能会导致您的错误。

© www.soinside.com 2019 - 2024. All rights reserved.