Trying to unit test a class which builds a static map within a class as follows:
private static Map<String, SomeClass> MAP = new HashMap<>();
static {
MAP = Map.ofEntries(
Map.entry(SOME_KEY, new SomeClass()),
.
.
.
Map.entry(SOME_KEY, new SomeClass())
);
}
When the map is being initialized during construction of the class I am getting the following error:
java.lang.NoSuchMethodError: java.util.Map.entry(Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map$Entry;
at package.ClassContainingMap.<clinit>(ClassContainingMap.java:36).
I have seen a similar post post on troubleshooting this error at How do I fix a NoSuchMethodError? and have tried cleaning and rebuilding as suggested in one place, but to no avail. The accepted response suggests that perhaps a separate library versions might be being used to compile and run the code, but I have no idea how to figure that out as I am relatively new to Android and Java development. I should note that the application is being built using desugaring to allow use of some newer functionality and am not sure if this may be related to that in some capacity?
Thanks in advance.