'How to get dependency version on compile time

I am using a library in my sdk.

A user might also use that library for his project. In my SDK, that library only works for specific version.

So, if user is also using that library (very likely he is going to be at higher version), I don't want to initialize/run (init method) that in my sdk (library is for tracing).

In Android, if two libraries having different sdk version are specified in dependency then it is going to pick the one with higher version?

I was thinking about getting library version on compile time and then check if the version is equivalent to my version and if yes, then only call the init function.

but I am not sure how to get a library version inside code. Is this possible? and if yes, how can I do it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source