title: No such instance field: RetrofitClient
body: <p>I'm trying to make an HTTP Client using retrofit 2 and since I'm used to working in Visual Studio I'm having a lot of trouble debugging my code and making it work.</p>
  
  <p>What in the earth is "No such instance field" error?</p>
  
  <p>Very poor help online so far so I have to write out this question.</p>
  
  <pre><code>public class ApiUtils {
      private ApiUtils() {}
  
      public static final String BASE_URL = "https://cloudlibraryapiserver.azurewebsites.net/";
  
      public static APIService getAPIService() {
          return RetrofitClient.getClient(BASE_URL).create(APIService.class);
      }
  }
  </code></pre>
  
  <p>This is my ApiUtils class...</p>
  
  <pre><code>public class RetrofitClient {
      private static Retrofit retrofit = null;
  
      public static Retrofit getClient(String baseUrl) {
          if (retrofit==null) {
              retrofit = new Retrofit.Builder()
                      .baseUrl(baseUrl)
                      .addConverterFactory(GsonConverterFactory.create())
                      .build();
          }
          return retrofit;
      }
  }
  </code></pre>
  
  <p>RetrofitClient class</p>
  
  <pre><code>public interface APIService {
      @GET("api/books")
      Call&lt;List&lt;Book&gt;&gt; getBooks();
  
      @POST("api/books")
      @FormUrlEncoded
      Call&lt;Book&gt; saveBook(@Field("title") String title,
                          @Field("authorID") int authorID);
  }
  </code></pre>
  
  <p>This is my APIService interface (why it doesn't have class implementation? I have no idea since I'm following example from Internet.)</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
      private APIService mAPIService;
      private ListView listView;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          // Set View Controls:
  
          listView = (ListView) findViewById(R.id.listViewBook);
  
          // Now do this:
          mAPIService = ApiUtils.getAPIService();
  
          Call&lt;List&lt;Book&gt;&gt; getBooksCall = mAPIService.getBooks();
  
          getBooksCall.enqueue(new Callback&lt;List&lt;Book&gt;&gt;() {
              @Override
              public void onResponse(Call&lt;List&lt;Book&gt;&gt; call, Response&lt;List&lt;Book&gt;&gt; response) {
                  List&lt;Book&gt; books = response.body();
  
                  listView.setAdapter(new BookAdapter(MainActivity.this, books));
              }
  
              @Override
              public void onFailure(Call&lt;List&lt;Book&gt;&gt; call, Throwable t) {
                  Toast.makeText(MainActivity.this, "something went wrong - check your internet connection",
                          Toast.LENGTH_SHORT).show();
              }
          });
      }
  }
  </code></pre>
  
  <p>When I call <strong>getBooksCall.enqueue</strong> line I get the following error:</p>
  
  <blockquote>
    <p>No such instance field: 'mAPIService'</p>
  </blockquote>
  
  <p>Other posts have accepted answer which said "Android Studio required a restart", I didn't try to restart Android studio but this definitely doesn't seem like right solution.</p>
  
  <p>I need in depth answer, someone with retrofit experience If you answer with how to do it I'm going to need STEP by STEP explanation not just ONE WORD answers like most of these Android questions have,</p>
  
  <p>This is the most frustrating thing ever trying to make this work and NO real answers to be found online...</p>