title: How to make Twilio Client Sdk compatible with latest android versions?
body: <p>I am using twilioclient-android-1.1.2-3635733 in my application, the MonkeyPhone Class file  seems like - </p>
  
  <pre><code>package com.twilio.example.hellomonkey;
  
  import java.util.HashMap;
  import java.util.Map;
  
  import android.content.Context;
  import android.util.Log;
  
  import com.twilio.client.Connection;
  import com.twilio.client.Device;
  import com.twilio.client.Twilio;
  import com.twilio.client.Connection.State;
  
  
  public class MonkeyPhone implements Twilio.InitListener
  {
      private static final String TAG = "MonkeyPhone";
      private Device device;
      private Connection connection;
      public MonkeyPhone(Context context)
      {
          Twilio.initialize(context, this /* Twilio.InitListener */);
      }
  
      /* Twilio.InitListener method */
      @Override
      public void onInitialized()
      {
          Log.d(TAG, "Twilio SDK is ready");
          try {
              String capabilityToken = HttpHelper.httpGet("http://www.google.com/twilio/auth.php");
              device = Twilio.createDevice(capabilityToken, null /* DeviceListener */);
          } catch (Exception e) {
              Log.e(TAG, "Failed to obtain capability token: " + e.getLocalizedMessage());
          }
      }
        /* Twilio.InitListener method */
      @Override
      public void onError(Exception e)
      {
          Log.e(TAG, "Twilio SDK couldn't start: " + e.getLocalizedMessage());
      }
  
      @Override
      protected void finalize()
      {
          if (connection != null)
              connection.disconnect();
          if (device != null)
              device.release();
      }
  
      public void connect(String phoneNumber) {
          Map&lt;String, String&gt; parameters = new HashMap&lt;String, String&gt;();
          parameters.put("PhoneNumber", phoneNumber);
          connection = device.connect(parameters, null /* ConnectionListener */);
          if (connection == null)
              Log.w(TAG, "Failed to create new connection");
          // TODO Auto-generated method stub
  
      }
  
      public void disconnect()
      {
          if (connection != null) {
              connection.disconnect();
              connection = null;
          }
          Twilio.shutdown();
      }
  
      public State status()
      {
          connection.getState();
          State statusHere = connection.getState();
          return statusHere;
      }
  
  
  }
  </code></pre>
  
  <p><strong>HelloMonkeyActivity</strong></p>
  
  <pre><code>package com.twilio.example.hellomonkey;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.os.StrictMode;
  import android.view.View;
  import android.widget.EditText;
  import android.widget.ImageButton;
  
  public class HelloMonkeyActivity extends Activity implements View.OnClickListener
  {
      private MonkeyPhone phone;
      private EditText numberField;
  
      @Override
      public void onCreate(Bundle bundle)
      {
          super.onCreate(bundle);
          if (android.os.Build.VERSION.SDK_INT &gt; 9) {
              StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
              StrictMode.setThreadPolicy(policy);
              }
          setContentView(R.layout.main);
          phone = new MonkeyPhone(getApplicationContext());
          ImageButton dialButton = (ImageButton)findViewById(R.id.dialButton);
          dialButton.setOnClickListener(this);
          ImageButton hangupButton = (ImageButton)findViewById(R.id.hangupButton);
          hangupButton.setOnClickListener(this);
          numberField = (EditText)findViewById(R.id.numberField);
      }
  
      @Override
      public void onClick(View view)
      {
          if (view.getId() == R.id.dialButton)
              phone.connect(numberField.getText().toString());
          else if (view.getId() == R.id.hangupButton)
              phone.disconnect();
      }
  }
  </code></pre>
  
  <p>I am using this with <code>targetSdkVersion:19</code> 
  Things work fine with emulator I have tested on following emulator devices -
  Nexus One (Android 4.4)
  Nexus 7 (Android 4.4)
  Nexus 10 (Android 4.4)
  and on devices with android 4.2 and 4.3 it works fine in emulator </p>
  
  <p>It works fine with real device Xolo A600 (Android version 4.2.2)
  But fails with following stacktree on any higher version to that in real devices not in emulator - Why so</p>
  
  <pre><code>02-19 11:58:38.492: E/AndroidRuntime(26854): FATAL EXCEPTION: Thread-18132
  02-19 11:58:38.492: E/AndroidRuntime(26854): Process: com.twilio.example.hellomonkey, PID: 26854
  02-19 11:58:38.492: E/AndroidRuntime(26854): java.lang.NoSuchFieldError: no type "Lcom/twilio/client/impl/useragent/config/UserAgentConfig$Callbacks;" found and so no field "callbacks" could be found in class "Lcom/twilio/client/impl/useragent/UserAgent;" or its superclasses
  02-19 11:58:38.492: E/AndroidRuntime(26854): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.twilio.client.impl.useragent.config.UserAgentConfig$Callbacks" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
  02-19 11:58:38.492: E/AndroidRuntime(26854):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
  02-19 11:58:38.492: E/AndroidRuntime(26854):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
  02-19 11:58:38.492: E/AndroidRuntime(26854):    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
  02-19 11:58:38.492: E/AndroidRuntime(26854):    Suppressed: java.lang.ClassNotFoundException: com.twilio.client.impl.useragent.config.UserAgentConfig$Callbacks
  02-19 11:58:38.492: E/AndroidRuntime(26854):        at java.lang.Class.classForName(Native Method)
  02-19 11:58:38.492: E/AndroidRuntime(26854):        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
  02-19 11:58:38.492: E/AndroidRuntime(26854):        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
  02-19 11:58:38.492: E/AndroidRuntime(26854):        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
  02-19 11:58:38.492: E/AndroidRuntime(26854):        ... 1 more
  02-19 11:58:38.492: E/AndroidRuntime(26854):    Caused by: java.lang.NoClassDefFoundError: Class "Lcom/twilio/client/impl/useragent/config/UserAgentConfig$Callbacks;" not found
  02-19 11:58:38.492: E/AndroidRuntime(26854):        ... 5 more
  02-19 11:58:49.404: I/Process(26854): Sending signal. PID: 26854 SIG: 9
  </code></pre>
  
  <p>I mean is it that the twilio sdk is for now compatible with only 4.2 for now but if so then why it runs fine in emulator Regarding the error I already posted here before
  <a href="https://stackoverflow.com/questions/21845185/how-to-resolve-java-lang-noclassdeffounderror-useragentconfigcallbacks-with-twi">How to resolve java.lang.NoClassDefFoundError UserAgentConfig$Callbacks with Twilio</a>
   but now with the code provided I guess you guys can help and understand my frustration -
  Thanks in advance</p>