title: RxJava Observer incompatible types
body: <p>I am trying to use Retrofit and RxJava to make an API call within a custom view in an app that I am working on, but I encounter an incompatible type error when trying to subscribe to the Observable from my Retrofit API call.</p>
  
  <p>My retrofit interface: </p>
  
  <pre><code>public interface ApiQueryInterface{
  // Request method and URL specified in the annotation
  // Callback for the parsed response is the last parameter
  
  @GET("users/")
  Observable&lt;Users&gt; getUsers (
          @Query("key") String key,
          @Query("address") String address
  );
  
  @GET("posts/")
  Observable&lt;Posts&gt; getPosts (
          @Query("key") String key,
          @Query("address") String address
  );
  </code></pre>
  
  <p>}</p>
  
  <p>and the Retrofit call located within the onFinishInflate() of the custom view:</p>
  
  <pre><code>        // Create RxJava adapter for synchronous call
      RxJava2CallAdapterFactory rxAdapter = RxJava2CallAdapterFactory.create();
  
      // Create Retrofit2 instance for API call
      Retrofit retrofit = new Retrofit.Builder()
              .baseUrl(BASE_URL)
              .addConverterFactory(GsonConverterFactory.create())
              .addCallAdapterFactory(rxAdapter)
              .build();
  
      // Make API call using retrofit
      final ApiQueryInterface apiQueryInterface = retrofit.create(ApiQueryInterface.class);
  
      // API return type defined by interface
      Observable&lt;Users&gt; query = apiQueryInterface
              .getUsers(KEY, ADDRESS)
              .subscribeOn(Schedulers.io())
              .observeOn(AndroidSchedulers.mainThread())
              .subscribe(new Observer&lt;Users&gt;() {
                  @Override
                  public void onSubscribe(Disposable d) {
  
                  }
  
                  @Override
                  public void onNext(Users users) {
  
                  }
  
                  @Override
                  public void onError(Throwable e) {
  
                  }
  
                  @Override
                  public void onComplete() {
  
                  }
              });
  }
  </code></pre>
  
  <p>When I build the project I hit an incompatible types error in the custom view on the line beginning with Observable&lt;Users&gt; query = ...:</p>
  
  <blockquote>
    <p>Error:(60, 27) error: incompatible types: void cannot be converted to Observable&lt;Users&gt;</p>
  </blockquote>
  
  <p>"Users" is a generic model class which matches the JSON object returned from the API</p>