我正在尝试从源代码运行此Android OCCI client。我无法登录,因为我得到null
异常,我无法调试。有罪的方法如下:
protected HttpResponse getResponse(String url) {
HttpResponse result = null;
try {
DefaultHttpClient httpclient = new DefaultHttpClient();
String username = getAccount().getUsername();
if (username != null && username.length() > 0) {
httpclient.getCredentialsProvider().setCredentials(new AuthScope(null, -1),
new UsernamePasswordCredentials(username, getAccount().getUserToken()));
Log.d(toString(), "Using Credentials " + username + " " + getAccount().getUserToken());
}
HttpGet get = generateHeader(url);
HttpResponse httpResp = httpclient.execute(get); //BOOM
int response = httpResp.getStatusLine().getStatusCode();
Log.d(toString(), url + " HttpResponse is " + response);
if (response == 200 || response == 204) {
result = httpResp;
}
} catch (Throwable t) {
Log.e("CloudServiceAdapter","Error connecting", t); /I inserted this
}
return result;
}
最初,catch区块什么也没做。我添加了一个日志语句,但我只得到“错误连接”作为输出。调试器说t
是null
,这在Java中是不可能的。我尝试将Throwable
更改为Exception
,但同样如此。还有其他与此问题有关的问题,但都没有帮助。
日志中唯一有趣的警告是
09-18 09:17:27.642: W/dalvikvm(1113): VFY: unable to resolve static method 1818: Lorg/apache/commons/codec/binary/Base64;.encodeBase64String ([B)Ljava/lang/String;
我尝试配置构建路径,检查“Order and export”中的所有JAR(它们在项目目录中的/ libs中),但是没有用。
我读到外部JAR必须由dx
处理,but Eclipse ADT应该自己运行它。
有什么想法吗?