I have this class public class LatLngBounds in module A that has 2 constructors:
public LatLngBounds(com.google.android.gms.maps.model.LatLngBounds google, com.huawei.hms.maps.model.LatLngBounds huawei)
public LatLngBounds(LatLng latLng1, LatLng latLng2)
So when I call the second constructor from another module B, I get the following compilation error:
error: cannot access LatLngBounds
private static final LatLngBounds ADELAIDE = new LatLngBounds(
However if I remove the first constructor, the error is gone. Note that marking it as private does not solve the problem.
I found out that I get this error only if there is another constructor with exactly same arity as the second constructor above. Other constructors that do not fulfil this condition do not trigger this error. It seems like this error is thrown only when the compiler needs to check overloaded constructors.
Note that module B does not have dependencies on com.google.android.gms.maps.model.LatLngBounds or com.huawei.hms.maps.model.LatLngBounds.
So my take on this is that it seems that when the compiler is trying to check this other constructor, it fails to find these classes and triggers the error.
You can check the problem in this repo, checkout tag 1.1.2.
So why is this error thrown? How can I keep both 2 constructors?