I'm trying to connect my Android Studio - app to an exchange webservice, but i keep getting the following error:
java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/message/BasicLineFormatter; in class Lorg/apache/http/message/BasicLineFormatter; or its superclasses (declaration of 'org.apache.http.message.BasicLineFormatter' appears in /system/framework/ext.jar)
Here are the.jars that ive added to /libs/ in my android project:
Here is the onCreate method were the error occurs:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ExchangeService service = new ExchangeService(); // this is where the error is hitting
ExchangeCredentials credentials = new WebCredentials("user", "pw");
service.setCredentials(credentials);
try {
service.setUrl(new URI("uri"));
} catch (URISyntaxException e) {
e.printStackTrace();
}
EmailMessage msg= null;
try {
msg = new EmailMessage(service);
msg.setSubject("Hello world!");
msg.setBody(MessageBody.getMessageBodyFromText("Sent using the EWS Java API."));
msg.getToRecipients().add("email");
msg.send();
} catch (Exception e) {
e.printStackTrace();
}
}
And my dependencies:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.0.0'
//compile 'org.apache.httpcomponents:httpclient:4.3'
//compile 'org.apache.httpcomponents:httpcore:4.3.3'
//compile 'commons-logging:commons-logging:1.2'
// compile 'joda-time:joda-time:2.7'
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
}
I'm currently working on a mac (if the screenshot didnt give it away), and as noted in Android Studio on a Android app.