title: java.lang.NullPointerException error on Retrofit onResponse
body: <p>Good day, I'm using Retrofit for the first time and I can't seem to get it to work. working on an app that get crypto currency rates in local currencies, here is the api <a href="https://min-api.cryptocompare.com/data/pricemulti?fsyms=BTC,ETH&amp;tsyms=USD,EUR,NGN" rel="nofollow noreferrer">link</a>, JSON format</p>
  
  <pre><code>{
    "BTC": {
      "USD": 6019.1,
      "EUR": 5139.44,
      "NGN": 2136243.25
    },
    "ETH": {
      "USD": 290.98,
      "EUR": 250.03,
      "NGN": 103031.01
    }
  }
  </code></pre>
  
  <p>Here are my models (from <a href="http://www.jsonschema2pojo.org/" rel="nofollow noreferrer">http://www.jsonschema2pojo.org/</a>): UPDATED</p>
  
  <pre><code>public class CryptoCurrency {
  
  @SerializedName("BTC")
  @Expose
  private BTC BTC;
  @SerializedName("ETH")
  @Expose
  private ETH ETH;
  
  public BTC getBTC() {
      return BTC;
  }
  
  public void setBTC(BTC BTC) {
      this.BTC = BTC;
  }
  
  public ETH getETH() {
      return ETH;
  }
  
  public void setETH(ETH ETH) {
      this.ETH = ETH;
  }
  
  public class BTC {
  
      @SerializedName("USD")
      @Expose
      private Double USD;
  
      @SerializedName("EUR")
      @Expose
      private Double EUR;
  
      @SerializedName("NGN")
      @Expose
      private Double NGN;
  
      public Double getUSD() {
          return USD;
      }
  
      public void setUSD(Double USD) {
          this.USD = USD;
      }
  
      public Double getEUR() {
          return EUR;
      }
  
      public void setEUR(Double EUR) {
          this.EUR = EUR;
      }
  
      public Double getNGN() {
          return NGN;
      }
  
      public void setNGN(Double NGN) {
          this.NGN = NGN;
      }
  
  
  }
  
  
  public class ETH {
  
      @SerializedName("USD")
      @Expose
      private Double USD;
      @SerializedName("EUR")
      @Expose
      private Double EUR;
      @SerializedName("NGN")
      @Expose
      private Double NGN;
  
      public Double getUSD() {
          return USD;
      }
  
      public void setUSD(Double USD) {
          this.USD = USD;
      }
  
      public Double getEUR() {
          return EUR;
      }
  
      public void setEUR(Double EUR) {
          this.EUR = EUR;
      }
  
      public Double getNGN() {
          return NGN;
      }
  
      public void setNGN(Double NGN) {
          this.NGN = NGN;
      }
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>My interface:</p>
  
  <pre><code>public interface CurrencyInterface {
      @GET("/data/pricemulti/")
      Call&lt;CryptoCurrency.BTC&gt; currency(@Query("crypto") String crypto, @Query("local") String local);
  }
  </code></pre>
  
  <p>my <code>onResponse</code> method:</p>
  
  <pre><code>call.enqueue(new Callback&lt;CryptoCurrency.BTC&gt;() {
          @Override
          public void onResponse(Call&lt;CryptoCurrency.BTC&gt; call, Response&lt;CryptoCurrency.BTC&gt; response) {
              String currency = response.body().toString();
              Toast.makeText(getApplicationContext(), "result " + currency, Toast.LENGTH_LONG).show();
              Log.i("MainActivity", currency);
  
          }
  
          @Override
          public void onFailure(Call&lt;CryptoCurrency.BTC&gt; call, Throwable t) {
  
          }
      });
  </code></pre>
  
  <p>When I run the code and check my log I get this error:</p>
  
  <pre><code>java.lang.NullPointerException
  at com.example.raynold.cryptorates.MainActivity$1.onResponse(MainActivity.java:53)
  at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:70)
  </code></pre>
  
  <p>UPDATED---------</p>
  
  <p>My MainActivity class</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  private RecyclerView mCurrencyRecycler;
  private Button mclickMe;
  private CurrencyAdapter mCurrencyAdapter;
  private List&lt;CryptoCurrency&gt; mCurrencyList;
  private CurrencyInterface mCurrencyInterface;
  private LinearLayoutManager mLinearLayoutManager;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      mCurrencyRecycler = (RecyclerView) findViewById(R.id.rv_rates);
      mLinearLayoutManager = new LinearLayoutManager(this);
      mCurrencyRecycler.setLayoutManager(mLinearLayoutManager);
      mCurrencyRecycler.setHasFixedSize(true);
      mclickMe = (Button) findViewById(R.id.click_me);
  
      mCurrencyInterface = ApiClient.getApiClient().create(CurrencyInterface.class);
  
      Call&lt;CryptoCurrency.BTC&gt; call = mCurrencyInterface.currency("BTC", "NGN");
  
      call.enqueue(new Callback&lt;CryptoCurrency.BTC&gt;() {
          @Override
          public void onResponse(Call&lt;CryptoCurrency.BTC&gt; call, Response&lt;CryptoCurrency.BTC&gt; response) {
              String currency = response.body().toString();
              Toast.makeText(getApplicationContext(), "result " + currency, Toast.LENGTH_LONG).show();
              Log.i("MainActivity", currency);
  
          }
  
          @Override
          public void onFailure(Call&lt;CryptoCurrency.BTC&gt; call, Throwable t) {
  
          }
      });
  
      mclickMe.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
  
          }
      });
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I will also like to know how i can get it to work with a recyclerview since the JSON is of object type not Array.</p>