troorl
troorl

Reputation: 1609

Android and IOException - strange error

I'm trying to write a basic application with HTTP GET request. Eclipse validated my code, but when I'm using IOException in Android console I'm getting 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?

Upvotes: 1

Views: 4402

Answers (3)

Elliott Hughes
Elliott Hughes

Reputation: 4665

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

Upvotes: 9

Chris Thompson
Chris Thompson

Reputation: 35598

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.

Upvotes: 0

Gabri van Lee
Gabri van Lee

Reputation: 135

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.

Upvotes: 0

Related Questions