Why does Retrofit enqueue produce null point exception? : <p>I have created my own test JSON and try to incorporate it into my <code>Android</code> app using <code>Retrofit</code> but for some reason I can´t seem to understand I get a <code>Null Point Exception</code> when trying to fetch the <code>JSON</code>. </p>

<p>I have created JSON that looks something like this:</p>

<pre><code>[{"date":"2019/01/01","availability":"available"},{"date":"2019/01/02","availability":"closed"},{"date":"2019/01/03","availability":"closed"}]
</code></pre>

<p>And so on...</p>

<p>Then I have set up both the <code>Retrofit</code> code and the <code>Room</code> database code.</p>

<p>Here is the <code>Retrofit</code> code from the main class:</p>

<pre><code>public class MainActivity extends AppCompatActivity {

MainRepository mainRepository;
Call&lt;List&lt;RFVariables&gt;&gt; getRFPosts;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate( savedInstanceState );
    setContentView( R.layout.activity_main );

    getRFPosts = mainRepository.getGetPosts();

    getRFPosts.enqueue( new Callback&lt;List&lt;RFVariables&gt;&gt;() {
        @Override
        public void onResponse(Call&lt;List&lt;RFVariables&gt;&gt; call, Response&lt;List&lt;RFVariables&gt;&gt; response) {
            List&lt;RFVariables&gt; myResponse = response.body();

            if(myResponse != null) {
                for(RFVariables item: myResponse) {
                    Log.d("TAG", item.getDate());

                }
            }

        }

        @Override
        public void onFailure(Call&lt;List&lt;RFVariables&gt;&gt; call, Throwable t) {

        }
    } );
</code></pre>

<p>It crashes on the <code>getRFPosts = mainRepository.getGetPosts();</code> line with the error <code>Attempt to invoke interface method 'void retrofit2.Call.enqueue(retrofit2.Callback)' on a null object reference
        at com.slothmode.sunnyatsea.MainActivity.onCreate(MainActivity.java:25)</code></p>

<p>The repository code looks like this:</p>

<pre><code>private Retrofit retrofitObject;
private RFCalls retrofitRepository;
private Call&lt;List&lt;RFVariables&gt;&gt; getPosts;

public MainRepository(Application application) {
    this.retrofitObject = new Retrofit.Builder()
            .baseUrl( "https://api.myjson.com/bins/" )
            .addConverterFactory( GsonConverterFactory.create() )
            .build();

    this.retrofitRepository = this.retrofitObject.create( RFCalls.class );
    this.getPosts = this.retrofitRepository.findPosts();
}

public Call&lt;List&lt;RFVariables&gt;&gt; getGetPosts() {
    return getPosts;
}
</code></pre>

<p>I have done this successfully before, so not sure what's mising this time around. Seems like an exact replica of my other successful projects. What am I missing? Let me know if there is more code I should show. Thanks in advance. Really stuck here.</p>
