Fix: Cannot resolve No versions available for org.osgi.service:org.osgi.service.prefs:jar:[1.1.0,1.2.0) within specified range Error

During the installation of Maven, I encountered an issue with JDT dependencies, which is as follows: Cannot resolve No versions available for org.osgi.service:org.osgi.service.prefs:jar:[1.1.0,1.2.0) within specified range in Java.

Why Cannot resolve No versions available for org.osgi.service:org.osgi.service.prefs:jar:[1.1.0,1.2.0) within specified range Error Occurs?

The groupId in your dependence is the cause of this problem. You may see org.osgi.service as a groupId, and groupId org.osgi.service does not exist, which is why Maven shows you that groupId org.osgi.service does not exist in this error and org.osgi should be your groupId.

How to fix Cannot resolve No versions available for org.osgi.service:org.osgi.service.prefs:jar:[1.1.0,1.2.0) within specified range Error?

To solve the error, use org.osgi as groupId rather to use the org.osgi.service which doesn’t exist.

The groupId in dependencies is the cause of this problem. You may see org.osgi.service as a groupId, and groupId org.osgi.service does not exist, which is why Maven shows you that groupId org.osgi.service does not exist in this error and org.osgi should be your groupId.

Below is the step-by-step process to solve the Cannot resolve No versions available for org.osgi.service:org.osgi.service.prefs:jar:[1.1.0,1.2.0) within specified range Error:

<dependency>
    <groupId>org.osgi</groupId>
    <artifactId>org.osgi.service.prefs</artifactId>
    <version>[1.1.0,1.2.0)</version>
</dependency>

Conclusion

Error Cannot resolve No versions available for org.osgi.service:org.osgi.service.prefs:jar:[1.1.0,1.2.0) within specified range occurs because of wrong groupId. To fix the error, call the right groupId, org.osgi as “<groupId>org.osgi</groupId>”.

Hope it should help you to fix the Cannot resolve No versions available for org.osgi.service:org.osgi.service.prefs:jar:[1.1.0,1.2.0) within specified range Error.