java - retrofit2.4 + 适配器-rxjava2 + proguard
问题描述
错误如下:
03-11 14:28:14.401 11858 11858 E AndroidRuntime: Caused by: java.lang.IllegalArgumentException: Unable to create call adapter for class io.reactivex.Flowable
03-11 14:28:14.401 11858 11858 E AndroidRuntime: for method RequestApis.getCameraInfo
03-11 14:28:14.401 11858 11858 E AndroidRuntime: at retrofit2.ServiceMethod$Builder.methodError()
03-11 14:28:14.401 11858 11858 E AndroidRuntime: at retrofit2.ServiceMethod$Builder.createCallAdapter()
03-11 14:28:14.401 11858 11858 E AndroidRuntime: at retrofit2.ServiceMethod$Builder.build()
03-11 14:28:14.401 11858 11858 E AndroidRuntime: at retrofit2.Retrofit.loadServiceMethod()
03-11 14:28:14.401 11858 11858 E AndroidRuntime: at retrofit2.Retrofit$1.invoke()
03-11 14:28:14.401 11858 11858 E AndroidRuntime: at java.lang.reflect.Proxy.invoke(Proxy.java:393)
03-11 14:28:14.401 11858 11858 E AndroidRuntime: at $Proxy0.getCameraInfo(Unknown Source)
03-11 14:28:14.401 11858 11858 E AndroidRuntime: at com.youlecamera.upload.helper.RetrofitHelper.getCameraInfo()
03-11 14:28:14.401 11858 11858 E AndroidRuntime: at com.youlecamera.awsIot.IotService.bind()
03-11 14:28:14.401 11858 11858 E AndroidRuntime: at com.youlecamera.awsIot.IotService.aZ()
03-11 14:28:14.401 11858 11858 E AndroidRuntime: at com.youlecamera.awsIot.IotService$1.onReceive()
03-11 14:28:14.401 11858 11858 E AndroidRuntime: at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:922)
03-11 14:28:14.401 11858 11858 E AndroidRuntime: ... 7 more
03-11 14:28:14.401 11858 11858 E AndroidRuntime: Caused by: java.lang.IllegalStateException: Flowable return type must be parameterized as Flowable<Foo> or Flowable<? extends Foo>
03-11 14:28:14.401 11858 11858 E AndroidRuntime: at retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory.get()
03-11 14:28:14.401 11858 11858 E AndroidRuntime: at retrofit2.Retrofit.nextCallAdapter()
03-11 14:28:14.401 11858 11858 E AndroidRuntime: at retrofit2.Retrofit.callAdapter()
我的前卫是:
我多次尝试修改proguard,但都没有成功,我该怎么办?谁能帮我?谢谢
我的代码如下,请帮忙检查,谢谢。
{
...
OkHttpClient client = clientBuilder.build();
Log.w(TAG, "RequestRetrofit", new Throwable());
...
String url = (version == Constants.VERSION_PRE) ? RequestApis.HOST : RequestApis._HOST;
Retrofit.Builder builder = new Retrofit.Builder()
.baseUrl(url)
.client(client)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create());
Retrofit retrofit = builder.build();
service = retrofit.create(RequestApis.class);
}
解决方案
推荐阅读
- c# - 使用凭据访问本地网络中的共享文件夹
- java - GenericFilterBean vs OncePerRequestFilter 什么时候使用?
- url - Google 列出了后缀为“?from=xiaodiaomao.com”的网站
- javascript - 在循环中如何引用主要的“this”?
- macos - 如何通过 HDMI 在 Macbook Pro 2017 上运行 4K 60 Hz
- string - 使用 Liquid 连接字符串
- openlayers - arcmap 10.6 shapefile 不显示在 OpenLayers 4.6.5 中
- elasticsearch - 查找 lucene 中匹配文档的出现次数
- asp.net-core - 创建自定义 Auth0 登录页面
- ios - ECDSA secp256k1 密钥对生成和在 Swift 上签名