Android和IOException - 奇怪的错误

tro*_*orl 1 java android

我正在尝试使用HTTP GET请求编写基本应用程序.Eclipse验证了我的代码,但是当我IOException在Android控制台中使用时,我收到了这些奇怪的消息:

麻烦写输出:null
[2009-07-29 17:22:49 - myapp]转换为Dalvik格式失败,错误2

我的应用程序没有加载到模拟器中.这是我的代码:

HttpHost target = new HttpHost("google.com", 80);
HttpGet get = new HttpGet("/");
String result = null;
HttpEntity entity = null;
HttpClient client = new DefaultHttpClient();
try {
    HttpResponse response=client.execute(target, get);
    entity = response.getEntity();
    result = EntityUtils.toString(entity);
} catch (Exception e) {
    e.printStackTrace();
} finally {
    if (entity!=null){}
        try {
            entity.consumeContent();
        } catch (IOException e) {}
}
return result;
Run Code Online (Sandbox Code Playgroud)

谁知道问题是什么?

Ell*_*hes 9

这种情况不时出现,但dx中没有任何错误被追踪.你有-XX:+ AggressiveOpts JVM选项吗?查看最新报告:

http://code.google.com/p/android/issues/detail?id=5817

这是与此stackoverflow页面相对应的错误(由于作者从未提供重现问题所需的信息,因此我关闭了该错误):

http://code.google.com/p/android/issues/detail?id=3480