Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: IllegalStateException in Android Support when executing Unit Tests

I'm trying to run some Unit Tests in Andoid Studio. In the "Run Configurations"-tab I've made it so that my JUnit searches the entire project for tests. My JRE is configured for 1.8 and I've got Code Coverage enabled. However, every time I try and run my tests, I get the following "IDE Fatal 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've tried to google a solution and this thread came close: NullPointerExcepton in Android Studio plugin Android Support, but my SDK's and plugins are up-to-date and that didn't really solve it.

Thanks already

like image 884
Wouter Vanherck Avatar asked Oct 17 '22 19:10

Wouter Vanherck


1 Answers

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

That should solve the issue.

like image 79
Nick Bleyen Avatar answered Oct 29 '22 19:10

Nick Bleyen