I need to use the same class on two diffwrent platform-SDKs.
Although the class and its methods are the same the path to access the class is different.
On one device I need to use:
while for the second device I need to use:
Please don't ask me why: I did not write the SDKs and I can't change them.
So the question is: how would you do it? Is there a way to import different versions of the same class on different sdk versions?
In C++ I would use a precompiler switch like:
You could write a light proxy layer and check which classes are available with
Class.forName(). This is the way to go if your two classes will diverge in signatures etc. in the future.
If, however, you are entirely sure they will always retain identical functionality, then just search and replace all instances of the import in question in your build tool. In maven you could use resource filtering, this question has an example.