square / retrofit

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

error: retrofit2.adapter.rxjava2.HttpException: HTTP 404 Not Found #2815

Closed kldMohammed closed 5 years ago

kldMohammed commented 6 years ago

when i use rxjava i got this error

error: retrofit2.adapter.rxjava2.HttpException: HTTP 404 Not Found at retrofit2.adapter.rxjava2.BodyObservable$BodyObserver.onNext(BodyObservable.java:54) 07-02 23:53:39.876 18974-20433/com.susham.salamtk W/System.err: at retrofit2.adapter.rxjava2.BodyObservable$BodyObserver.onNext(BodyObservable.java:37) at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:44) at io.reactivex.Observable.subscribe(Observable.java:12036) at retrofit2.adapter.rxjava2.BodyObservable.subscribeActual(BodyObservable.java:34) at io.reactivex.Observable.subscribe(Observable.java:12036) at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeTask.run(ObservableSubscribeOn.java:96) at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:579) at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66) at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 07-02 23:53:39.876 18974-20433/com.susham.salamtk W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 07-02 23:53:39.877 18974-20433/com.susham.salamtk W/System.err: at java.lang.Thread.run(Thread.java:818)

this is my configration

without rxjava adapter it works fine i try it both in the same activity to be sure it work

@GET("api/Ambulancetypes") fun getAmbulanceTypes(): Observable<List> //

private val builder = Retrofit.Builder() .baseUrl(BASE_URL) .addConverterFactory(GsonConverterFactory.create()) .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) .client(okHttpClient.build()) var retrofit = builder.build()

// apiService.getAmbulanceTypes() .subscribeOn(Schedulers.io()) .subscribeOn(AndroidSchedulers.mainThread()) .subscribe(this::handleResponse, this::handleError)

//

implementation "com.squareup.retrofit2:retrofit:$retrofit_version"

 implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"

ext{ retrofit_version = "2.4.0" }

chjan commented 6 years ago

I have the same problem, but a temporary remedy could be to download the jar and store in /libs. It was found, but Android Studio did not detect it, regardless of cache invalidation etc.

I am having trouble using this adapter (not necessarily the cause of error) in version 1.0.0. trying to do a supersimple HTTP GET. Could this library in v1 be the problem? How to get hold of the latest version 2.4.0 from Maven?

thrwatzidan commented 6 years ago

.subscribeOn(AndroidSchedulers.mainThread())

change it to .observeOn(AndroidSchedulers.mainThread())

or there is error with your http://1.0.0.2/file name/ try to check your file name

JakeWharton commented 5 years ago

I can't reproduce this behavior and I have a hard time seeing how it could happen. Please provide a sample that reliably reproduces the problem or a failing test case that can be debugged.

kldMohammed commented 5 years ago

Now i get rid of all the rx qnd replaced it with a coroutine