tags:

views:

518

answers:

3

Hi. I'm trying to write a basic application with http get request. Eclipse validated my code, but when I using IOException in Android console I have this strange messages:

trouble writing output: null
[2009-07-29 17:22:49 - myapp] Conversion to Dalvik format failed with error 2

And my application doesn't load into the emulator. This is my code:

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;

Anyone knows what is the problem?

A: 

This might not apply to you, but I got the very same error running Eclipse with the Android SDK under Windows 7. The problem could be solved by saving the project, closing and restarting Eclipse and reopening the project.

Gabri van Lee
Unfortunately, I got this error on Ubuntu 9.04. On WindowsXP all OK. Reopening the project doesn't help.
troorl
A: 

What's happening is it's actually failing to compile so log statements won't help and also explains why it won't load into the emulator. If it's an IOException that's being thrown there's a good chance there's a problem with the output process, perhaps attempting to write to a location it doesn't have permission to, etc. There's also a possibility that you're using an unsupported library. Check out this site for a similar error. Not sure if you're doing anything like that, but it's worth a look.

Chris Thompson
+1  A: 

this pops up every now and again, but no bug in dx has yet been tracked down. do you have the -XX:+AggressiveOpts JVM option? see the most recent report:

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

and here's the bug corresponding to this stackoverflow page (which i closed because the author never supplied information we needed to reproduce the problem):

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

Elliott Hughes