I was also getting this same error on a fresh install when testing in Android Studio. In my case I changed the name of the testPackageName. This was the same as the default package name.
Now the tests are running smoothly. I don't know why it worked but it did. Increasing the versionCode should have worked but it didn't.