【发布时间】:2015-03-27 21:44:58
【问题描述】:
我正在尝试将我的 Android Studio - 应用程序连接到交换网络服务,但我不断收到以下错误:
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)
这是我在我的 android 项目中添加到 /libs/ 的 .jars:
这是发生错误时的 onCreate 方法:
@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();
}
}
还有我的依赖:
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'
}
我目前正在使用 mac(如果屏幕截图没有泄露的话),并且如 Android 应用程序上的 Android Studio 中所述。
【问题讨论】:
-
@dhke 尝试在评论部分导入一个,现在得到:
Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2 -
带有有趣信息的错误消息很可能略高于此。
-
@dhke
com.android.dex.DexException: Multiple dex files define Lorg/apache/http/Consts;越来越近了!
标签: java android android-studio apache-httpclient-4.x