5

When I try to close a socket through its Closeable interface, I get an exception:

new java.net.Socket().close();
// no error

((java.io.Closeable) new java.net.Socket()).close();
// Throws: java.lang.IncompatibleClassChangeError: interface not implemented

Why is that? The problem is only on Android devices, not on Java programs running on desktop.

1 Answer 1

13

To quote Android issue tracker:

Socket implements Closeable only since API level 19 (kitkat) but that information isn't in the generated documentation.

Sign up to request clarification or add additional context in comments.

1 Comment

This is a bad lack on the Android documentation... they should find a way to indicate that an interface is implemented (or a class is extended) only since a defined API level. However, thanks :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.