3

I recently upgraded from retroft-beta1 and this was working. I have the following interface for the API:

public interface Service {
    @POST("path")
    Observable<Object> service();
}

And the following call:

service.service()
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe();

And it throws a NetworkOnMainThreadException. But this was working in retrofit-beta1.

bryant1410
  • 5,540
  • 4
  • 39
  • 40

1 Answers1

8

From retrofit-beta2, calls to Observable methods now behave synchronously. So subscribeOn must be used:

service.service()
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe();
bryant1410
  • 5,540
  • 4
  • 39
  • 40