square / retrofit

A type-safe HTTP client for Android and the JVM
https://square.github.io/retrofit/
Apache License 2.0
42.97k stars 7.3k forks source link

NoClassDefFoundError when using Completable #2087

Closed pbochenski closed 7 years ago

pbochenski commented 7 years ago

Hi I try to use Retrofit2 with RxJava bindings and got this crash:

FATAL EXCEPTION: main
Process: com.kovanen, PID: 24789
java.lang.NoClassDefFoundError: retrofit2.adapter.rxjava.CompletableHelper$CompletableCallOnSubscribe
at retrofit2.adapter.rxjava.CompletableHelper$CompletableCallAdapter.adapt(CompletableHelper.java:85)
at retrofit2.adapter.rxjava.CompletableHelper$CompletableCallAdapter.adapt(CompletableHelper.java:73)
at retrofit2.Retrofit$1.invoke(Retrofit.java:147)
at java.lang.reflect.Proxy.invoke(Proxy.java:393)
at $Proxy5.updateUserDetails(Unknown Source)
at com.kovanen.repository.NetworkAuthorizedApiRepo.updateUserDetails(AuthorizedApiRepo.kt:17)
at com.kovanen.usecases.UpdateUserDetailsUseCase.buildObservable(UserUseCases.kt:17)
at com.kovanen.framework.UseCaseExecutor.execute(UseCase.kt:22)
at com.kovanen.activities.loggingActivity.UserDetailsPresenter.okClicked(UserDetailsActivity.kt:137)
at com.kovanen.activities.loggingActivity.UserDetailsActivity$onCreate$1.onClick(UserDetailsActivity.kt:53)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

my interface method looks like this:

@PATCH("users/{accountId}")
    fun updateUserDetails(@Path("accountId") id: Long, @Body data: UpdateUserDetailsBody): Completable

and my gradle config:

    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'
    compile 'com.squareup.okhttp3:logging-interceptor:3.3.1'
    compile 'io.reactivex:rxjava:1.2.1'
    compile 'io.reactivex:rxandroid:1.2.1'

It is on debug build so it is not cut out by proguard. Sidenote: I'm using Kotlin so returning Observable<Void> crashes app (trying to call onNext(null))

any help?

JakeWharton commented 7 years ago

Completable changed in a backwards-incompatible way in RxJava 1.2.0. Either use an older version of RxJava or use the latest SNAPSHOT version of Retrofit which has already fixed the issue. It will be released in a few weeks.

PaulWoitaschek commented 7 years ago

Any news on a new release? I don't want to use a snapshot version so I'm still stuck with rxJava 1.1.10

pbochenski commented 7 years ago

You can also use Single<Response<Void>>, but then you need to handle http errors manually.

asbadve commented 7 years ago

Any News

JakeWharton commented 7 years ago

The UK triggered Article 50 which means Brexit is happening.

On Sat, Apr 1, 2017 at 12:15 PM Ajinkya notifications@github.com wrote:

Any News

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/square/retrofit/issues/2087#issuecomment-290929980, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEEXP0SNsVgzoj9NiJVn1qjoMaAykrks5rrngJgaJpZM4K2aKx .