IllegalStateException in Android Support when executing unit tests

I am trying to run some Unit tests in Andoid Studio. In the "Run Configurations" -tab, I made it so that my JUnit would look at the entire project for tests. My JRE is set to 1.8 and I have Code Coverage enabled. However, every time I try to run my tests, I get the following "Fatal IDE Errors":

Unable to determine list of modules to build java.lang.IllegalStateException: Unable to determine list of modules to build at com.android.tools.idea.gradle.run.MakeBeforeRunTaskProvider.createBuilder(MakeBeforeRunTaskProvider.java:357) at com.android.tools.idea.gradle.run.MakeBeforeRunTaskProvider.executeTask(MakeBeforeRunTaskProvider.java:255) at com.android.tools.idea.gradle.run.MakeBeforeRunTaskProvider.executeTask(MakeBeforeRunTaskProvider.java:86) at com.intellij.execution.impl.ExecutionManagerImpl$3.run(ExecutionManagerImpl.java:317) at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:369) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) 

I tried to find a Google solution, and this thread came close: NullPointerExcepton in the Android Android Android plugin , but my SDKs and plugins are up-to-date and that didn't really solve it.

Thanks already

+5
source share
1 answer

In "Run Configurations", "Test kind" should be changed from "All in package" to "All in directory". By doing this, you can configure the "Use module path for module" field in the application. The Directory field should also point to your test directory.

This should solve the problem.

+3
source

Source: https://habr.com/ru/post/1262682/


All Articles