When trying to run some Android unit tests, I was getting a java.lang.IllegalAccessError: cross-loader access from pre-verified class error. After Googling I came across this helpful answer on Stack Overflow, which linked through this article: Android Testing: External Libraries

Basically, the problem was being caused by me using an external jar file in my project and unit tests. There were 2 steps I needed to follow to fix things:

  1. Export the external jar file from the main project i.e. not the test project
  2. Remove the reference to the external jar file from my test project

Et voila - my unit tests were up and running. Getting them all to pass was another matter though :)