I'm writing a library that requires some of the functionality provided by the javax.imageio.ImageIO class. Android does not provide these classes, but instead exposes similar functionality through android.graphics.Bitmap and related classes. It should be pretty easy to abstract away this functionality behind an interface, but I'm having trouble figuring out a good way to automatically load the correct implementation for a platform.
I initially looked at java.util.ServiceLoader, which looked like it would do the job perfectly, but it appears that it is broken in android. I've also looked at some heavier solutions like OSGi, but they really seem like overkill.
Is there an easy way to write two implementations for an interface and then load the correct one based on whether the code is running on Android vs the Desktop?