У меня есть модифицированный интерфейс API на kotlin:
interface CommonApi {
@GET("config")
fun getConfig(): Single<ConfigModel>
}
Я использую его с RxJava.Мой провайдер по модернизации:
Retrofit.Builder()
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create(gson))
.client(okHttpClient)
.baseUrl(HTTP_URL)
.build()
Когда я использую его без Proguard, он работает нормально.Но с Proguard я получил исключение (деобфусцированная трассировка стека):
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp/com.myapp.activities.SplashActivity}: java.lang.IllegalArgumentException: Unable to create call adapter for g.i<com.myapp.main.model.ConfigModel>
for method CommonApi.getConfig
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.IllegalArgumentException: Unable to create call adapter for g.i<com.myapp.main.model.ConfigModel>
for method CommonApi.getConfig
at retrofit2.ServiceMethod$Builder.build(Unknown Source)
parseMethodAnnotation
parseHttpMethodAndPath
parseHeaders
parseParameter
parseParameterAnnotation
validatePathName
methodError
methodError
parameterError
parameterError
at retrofit2.ServiceMethod$Builder.createCallAdapter(Unknown Source)
at retrofit2.ServiceMethod$Builder.build(Unknown Source)
parseMethodAnnotation
parseHttpMethodAndPath
parseHeaders
parseParameter
parseParameterAnnotation
validatePathName
methodError
methodError
parameterError
parameterError
at retrofit2.Retrofit.create(Unknown Source)
loadServiceMethod
callFactory
callAdapter
nextCallAdapter
requestBodyConverter
nextRequestBodyConverter
nextResponseBodyConverter
at retrofit2.Retrofit$1.invoke(Unknown Source)
at java.lang.reflect.Proxy.invoke(Proxy.java:397)
at $Proxy4.getConfig(Unknown Source)
at com.myapp.main.interactor.FirstLoadingInteractor.refreshConfig(Unknown Source)
at com.myapp.mvp.presenters.SplashPresenter.firstLoading(Unknown Source)
onSaveInstanceState
at com.myapp.activities.SplashActivity.onCreate(Unknown Source)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
... 10 more
Caused by: java.lang.IllegalArgumentException: Could not locate call adapter for g.i<com.myapp.main.model.ConfigModel>.
Tried:
* f.a.a.e
* f.f
at retrofit2.Retrofit.create(Unknown Source)
loadServiceMethod
callFactory
callAdapter
nextCallAdapter
requestBodyConverter
nextRequestBodyConverter
nextResponseBodyConverter
at retrofit2.Retrofit.create(Unknown Source)
loadServiceMethod
callFactory
callAdapter
nextCallAdapter
requestBodyConverter
nextRequestBodyConverter
nextResponseBodyConverter
Если я изменяю тип возвращаемого значения с Single
на Observable
, он будет нормально работать с Proguard :
interface CommonApi {
@GET("config")
fun getConfig(): Observable<ConfigModel>
}
В чем причина этой проблемы?Как я могу решить эту проблему и использовать Singles с модернизацией?