Java modules can't depend on Android Modules, only Android Modules can depend on Java Modules, as stated in the linked questions error as well.
If you are building a module for testing, to be used in you app's unit tests, that module can be simply an Android Library momdule, doesn't need to be a Java Module.
In an Application module (or Android Library module) you can have aar as test dependencies, like testImplementation "io.reactivex.rxjava2:rxandroid:2.0.1"
.
However, if your code under test actually interacts with Android SDK, you will need to mock those. In such case, first you will need to consider to just write AndroidTest instead. If it is important to be unit class, then you might want to look into using robolectric.