My Android studio project has an app module which is android framework dependent, I have created a new module called domain and it contains only pure java classes and a few test classes.
In this module's build.gradle file, I have added junit and mockito libraries for testing purpose as follows:
apply plugin: 'java'
sourceCompatibility = 1.7
targetCompatibility = 1.7
!!! JUnit version 3.8 or later expected
I managed to solve the problem by by changing the following in .iml file
<component name="NewModuleRootManager" inherit-compiler-output="true">
<orderEntry type="inheritedJdk" />