I have a suite of unit tests that run fine when run via ./gradlew :project:testDebugUnitTests. However, when I run them in Android Studio, I get an obscure issue that I eventually traced to what seems to be Android Studio using a different classpath from this Gradle command.
The dependency in question is Byte Buddy and I'm running into a variant of this bug which was fixed in 1.9.0. Running ./gradlew dependencies indicates that 1.9.10 will be used in my build, but when I look at the command line that Android Studio is using to run my tests, the -classpath argument includes both 1.8.10 and 1.9.10, and the 1.8.10 version is first in the list.
I'm really puzzled by what could be causing this, since I would have expected that Android Studio would get the classpath from its Gradle integration. I'd love any leads for why this could be happening or how to debug further.