title: Error: IllegalArgumentException: Unable to create call adapter for retrofit2.Response
body: <p>I have gone through this tutorial (<a href="http://www.duchess-france.org/accelerometer-time-series-and-prediction-with-android-cassandra-and-spark/" rel="nofollow noreferrer">http://www.duchess-france.org/accelerometer-time-series-and-prediction-with-android-cassandra-and-spark/</a>) to create an Accelerometer Rest API, just to see the data values on my localhost server at endpoint (<a href="http://192.168.0.104/acceleration" rel="nofollow noreferrer">http://192.168.0.104/acceleration</a>). But I'm facing an error "unable to create call adapter for retrofit2.Response"</p>
  
  <p>However in the tutorial Retrofit (&lt; 2.0) was used, I'm using Retorfit2.0 (2.1). So few changes have been made according to the updated library. </p>
  
  <p>Here is my below <strong>AccelerometerAct.java</strong></p>
  
  <pre><code>package accelerometer.sensor.com.acceleration;
  
  import android.hardware.Sensor;
  import android.hardware.SensorEvent;
  import android.hardware.SensorEventListener;
  import android.hardware.SensorManager;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  import android.view.View;
  import android.widget.Button;
  import android.widget.TextView;
  
  import java.util.Date;
  
  import accelerometer.sensor.com.acceleration.model.Acceleration;
  import retrofit2.Retrofit;
  
  
  
  public class AccelerometerAct extends AppCompatActivity implements SensorEventListener{
  
      private String restURL;
      private TextView acceleration;
      private Button myStartButton;
      private Button myStopButton;
  
      private AccelerometerAPI accelerometerAPI;
  
      private SensorManager sm;
      private Sensor accelerometer;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.accelerometer_activity);
          acceleration = (TextView) findViewById(R.id.acc);
  
  
          sm = (SensorManager) getSystemService(SENSOR_SERVICE);
          accelerometer = sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
  
          initRestApi();
          initActionButtons();
      }
  
      @Override
      protected void onResume() {
          super.onResume();
      }
  
  
      @Override
      public void onSensorChanged(SensorEvent event) {
          Acceleration capturedAcceleration = getAccelerationFromSensor(event);
          updateTextView(capturedAcceleration);
          new SendAccelerationAsyncTask().execute(capturedAcceleration);
      }
  
      @Override
      public void onAccuracyChanged(Sensor sensor, int accuracy) {
          //Do nothing
      }
  
      private void initRestApi() {
          Bundle extras = getIntent().getExtras();
          if (extras != null) {
              restURL = extras.getString(MainActivity.URL);
          }
  
          Retrofit restAdapter = new Retrofit.Builder()
                  .baseUrl(restURL)
                  .build();
  
          accelerometerAPI = restAdapter.create(AccelerometerAPI.class);
      }
  
  
      private void initActionButtons() {
          myStartButton = (Button) findViewById(R.id.start);
          myStopButton = (Button) findViewById(R.id.stop);
  
          myStartButton.setVisibility(View.VISIBLE);
          myStopButton.setVisibility(View.GONE);
  
          myStartButton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  startSensor();
                  myStartButton.setVisibility(View.GONE);
                  myStopButton.setVisibility(View.VISIBLE);
              }
          });
  
          myStopButton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  stopSensor();
                  myStartButton.setVisibility(View.VISIBLE);
                  myStopButton.setVisibility(View.GONE);
                  finish();
              }
          });
      }
  
      private void startSensor() {
          sm.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_NORMAL);
      }
  
      private void stopSensor() {
          sm.unregisterListener(this);
      }
  
  
      private void updateTextView(Acceleration capturedAcceleration) {
          acceleration.setText("X:" + capturedAcceleration.getX() +
                  "\nY:" + capturedAcceleration.getY() +
                  "\nZ:" + capturedAcceleration.getZ() +
                  "\nTimestamp:" + capturedAcceleration.getTimestamp());
      }
  
  
      private Acceleration getAccelerationFromSensor(SensorEvent event) {
          long timestamp = (new Date()).getTime() + (event.timestamp - System.nanoTime()) / 1000000L;
          return new Acceleration(event.values[0], event.values[1], event.values[2], timestamp);
      }
  
  
      private class SendAccelerationAsyncTask extends AsyncTask&lt;Acceleration, Void, Void&gt;{
  
          @Override
          protected Void doInBackground(Acceleration... params) {
              try {
                  accelerometerAPI.sendAccelerationValues(params[0]);
              } catch(Exception e) {
                  e.printStackTrace();
              }
              return null;
          }
      }
  </code></pre>
  
  <p>}</p>
  
  <p>Here is my <strong>MainActivity.java</strong></p>
  
  <pre><code>package accelerometer.sensor.com.acceleration;
  
  import android.content.Intent;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  
  public class MainActivity extends AppCompatActivity {
  
      public static final String URL = "restURL";
      private EditText restURL;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          restURL = (EditText) findViewById(R.id.inUrl);
  
          final Button myStartButton = (Button) findViewById(R.id.startAct);
          myStartButton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent intent = new Intent();
                  intent.setClass(MainActivity.this, AccelerometerAct.class);
                  intent.putExtra(URL, restURL.getText().toString());
                  startActivity(intent);
              }
          });
      }
  }
  </code></pre>
  
  <p>And my <strong>Acceleration.java</strong> model</p>
  
  <pre><code>    package accelerometer.sensor.com.acceleration.model;
  
  
  
  public class Acceleration {
  
      private long timestamp;
      private double x;
      private double y;
      private double z;
  
      public Acceleration(float x_value, float y_value, float z_value, long     timestamp) {
          x= new Double(""+x_value);
      y= new Double(""+y_value);
      z= new Double(""+z_value);
          this.timestamp = timestamp;
      }
  
      public long getTimestamp() {
          return timestamp;
      }
  
      public double getX() {
          return x;
      }
  
      public double getY() {
          return y;
      }
  
      public double getZ() {
          return z;
      }
  }
  </code></pre>
  
  <p>Here is my <strong>interface AccelerometerAPI.java</strong></p>
  
  <pre><code>package accelerometer.sensor.com.acceleration;
  
  
  import accelerometer.sensor.com.acceleration.model.Acceleration;
  import retrofit2.Response;
  import retrofit2.http.Body;
  import retrofit2.http.POST;
  
  
  
  public interface AccelerometerAPI {
  
      @POST("/acceleration")
      Response&lt;Acceleration&gt; sendAccelerationValues(@Body Acceleration acceleration);
  }
  </code></pre>
  
  <p><strong>Here is the logcat showing the error</strong></p>
  
  <pre><code>**01-24 09:25:48.439 1968-2023/accelerometer.sensor.com.acceleration 
  
  W/System.err: java.lang.IllegalArgumentException: Unable to create call adapter for retrofit2.Response&lt;accelerometer.sensor.com.acceleration.model.Acceleration&gt;**
  01-24 09:25:48.439 1968-2023/accelerometer.sensor.com.acceleration W/System.err:     for method AccelerometerAPI.sendAccelerationValues
  01-24 09:25:48.439 1968-2023/accelerometer.sensor.com.acceleration W/System.err:     at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:720)
  01-24 09:25:48.439 1968-2023/accelerometer.sensor.com.acceleration W/System.err:     at retrofit2.ServiceMethod$Builder.createCallAdapter(ServiceMethod.java:234)
  01-24 09:25:48.439 1968-2023/accelerometer.sensor.com.acceleration W/System.err:     at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:160)
  01-24 09:25:48.439 1968-2023/accelerometer.sensor.com.acceleration W/System.err:     at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:166)
  01-24 09:25:48.439 1968-2023/accelerometer.sensor.com.acceleration W/System.err:     at retrofit2.Retrofit$1.invoke(Retrofit.java:145)
  01-24 09:25:48.439 1968-2023/accelerometer.sensor.com.acceleration W/System.err:     at java.lang.reflect.Proxy.invoke(Proxy.java:393)
  01-24 09:25:48.439 1968-2023/accelerometer.sensor.com.acceleration W/System.err:     at $Proxy0.sendAccelerationValues(Unknown Source)
  01-24 09:25:48.439 1968-2023/accelerometer.sensor.com.acceleration W/System.err:     at **accelerometer.sensor.com.acceleration.AccelerometerAct$SendAccelerationAsyncTask.doInBackground(AccelerometerAct.java:134)**
  01-24 09:25:48.439 1968-2023/accelerometer.sensor.com.acceleration W/System.err:     at **accelerometer.sensor.com.acceleration.AccelerometerAct$SendAccelerationAsyncTask.doInBackground(AccelerometerAct.java:129)**
  01-24 09:25:48.439 1968-2023/accelerometer.sensor.com.acceleration W/System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:295)
  01-24 09:25:48.439 1968-2023/accelerometer.sensor.com.acceleration W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
  01-24 09:25:48.439 1968-2023/accelerometer.sensor.com.acceleration W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
  01-24 09:25:48.439 1968-2023/accelerometer.sensor.com.acceleration W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
  01-24 09:25:48.439 1968-2023/accelerometer.sensor.com.acceleration W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
  01-24 09:25:48.441 1968-2023/accelerometer.sensor.com.acceleration W/System.err:     at java.lang.Thread.run(Thread.java:818)
  </code></pre>