java.lang.NoClassDefFoundError:android and junit test

Not sure if I had the same problem as you but I am using gradle and for some reason the tests just wouldn’t run anymore, with the same error as you had. I tried cleaning and rebuilding but to no avail. After hours of frustration and trying to find an answer I came across the simple solution in a GitHub thread:

I resolved this issue by removing the .gradle folder in my project and rebuilding the project.

(thanks to vpetrov)

Leave a Comment