The problem is that Android Studio overwrites your .iml file very often, so although you modified it, it probably was changed.
Option 1 : hack it for Android Studio
Instead, you should set the class path as a virtual machine parameter in your test run and put the path to JUnit 4 in front of everything else.
In the test run configuration for VM options, add -classpath , then the path to JUnit, and then the rest of your class path (you can extract this from Android Studio output when you try to run the test, and it does not work, it is in the first line of output, where You have copied your message).
For example:
-classpath "/Users/anothem/.gradle/caches/artifacts-26/filestore/junit/junit/4.11/jar/4e031bb61df09069aeb2bffb4019e7a5034a4ee0/junit-4.11.jar:[the rest of your classpath]
Option 2: Use IntelliJ
This is actually not a problem, but I thought I mentioned it. If you really don't want to hang on Android Studio, you can use IntelliJ instead (Android Studio "dad").
With IntelliJ, you can open the project settings and simply reorder your packages so that JUnit4 and Robolectric come in front of everything else.
Alex Florescu Jul 27 '14 at 17:49 2014-07-27 17:49
source share