Had the same message. I had to remove the Run/Debug configuration.
In my case, I ran the unit test as a local test before. After that I moved my test to the androidTest package and tried to run it again. Android Studio remembered the last run configuration so it tried to run it again as a local unit test which produced the same error.
After removing the config and running the test again it generated a new configuration and worked.
I went to
File -> Invalidate Caches/Restart...
and then it worked for me.
I had the same issue. I rebuilded project, and it helped me.
Go to Build --> Rebuild Project
After then, if you are using Maven tool, I recommend use option Reimport All Maven Projects
If it not help, try another possible solutions:
or:
or:
or:
This might also happen, if your test folder has been imported as a separate module (a small square is shown on the folder icon in the project view).
Remove the module by selecting the test folder in the project view and press DEL.
Then start your test.
If a popup dialog appears with an error message, that no module is selected, specify your root module from the dropdown.
In my case, I had everything else in the right place, but I was working on a java library with kotlin. I just forgot to apply the plugin:
apply plugin: 'kotlin-android'
And now it's working as expected now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With