qq_36440137 2017-01-10 14:04 采纳率: 0%
浏览 1581

使用Rxjava+Retrofit时出错

楼主是萌新,在使用Rxjava2+retrofit2时编译完成之后会报错:

Caused by: java.lang.IllegalArgumentException: Unable to create call adapter for io.reactivex.Observablefor method NewsService.getUser

依赖:

compile 'io.reactivex.rxjava2:rxjava:2.0.4'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.squareup.okhttp3:okhttp:3.5.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'

部分代码:

Retrofit retrofit = new Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.baseUrl("http://takeapp.com.cn/Home/register/")
.build();
NewsService api = retrofit.create(NewsService .class);
api.getUser("13222222222",MD5Tool.md5("123"));
Service类接口:
@POST("login")
Observable getUser(@Field("phone_num") String username,
@Field("password") String password);

请问要如何解决

  • 写回答

1条回答

  • dabocaiqq 2017-01-14 14:52
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考