com.sun.jdi.internalException:Un

2017-07-28  本文已影响0人  管浩然

retrofit2+RxJava2 的一些坑

今天开发新项目,本着积极向上的学习态度,经过多番考虑我决定使用retrofit2 + RxJava2来做为我的网络请求......神说:你的想法非常好

    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.5.0'
    compile 'io.reactivex.rxjava2:rxjava:2.0.7'
    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'

首先我们先来看几个错误,如果有符合你项目错误的地方可以继续看 因为我都已经调试好了没办法截图我就把错误复制进来好了

com.sun.jdi.internalException:Unexpected JDWP Error:103
Unable to create call adapter for io.reactivex
Method threw 'java.lang.IllegalArgumentException' exception.
java.net.UnknownHostException: Unable to resolve host "h5www.kaixinwan.com": No address associated with hostname

  baseApi = retrofit.create(BaseApi.class);
  >>>>>Observable findObservable = baseApi.getFind(scy_type);<<<<<
旧的:compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
新的:compile 'com.squareup.retrofit2:adapter-rxjava2:2.2.0'
这里写图片描述

compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0-beta4' 网上说加这个依赖
大家不用试了 不好使!!!!!

 retrofit = new Retrofit.Builder()
                    .baseUrl(BaseUrl)
                    .client(build)
                    .addConverterFactory(FastJsonConverterFactory.create())
                    .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                    .build();


如果帮你解决了 给个喜欢呗



上一篇 下一篇

猜你喜欢

热点阅读