lase
lase

Reputation: 2634

Android Studio - Cannot run tests because java can't be found?

I'm unable to run my unit tests that I was previously able to in Android Studio, and I am totally lost. Here's the error that's thrown:

Caused by: java.io.IOException: Cannot run program ""/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java"": error=2, No such file or directory

Some background: I think there is a chance that this has to do with the fact that I was previously trying to run gradle from the command line. Since this is a new machine, gradle complained that there was no java install. Further, $ java -verison would bring up the Mac system dialog prompting me to install Java. So, I installed java via homebrew and symlinked it into /Library/Java/JavaVirtualMachines, and java began being picked up from the command line.

Worried that this was creating my issue, I removed the homebrew installation and symlinks, prompting command line invocations of java/gradle to start complaining again.

My final attempt at a fix was to set the Android Studio jdk as JAVA_HOME, but I'm still getting this error.

I can build apps and the APK just fine, but tests won't run no matter what I try. Any shred of insight is appreciated.

Upvotes: 5

Views: 1822

Answers (1)

Nemanja
Nemanja

Reputation: 3669

I faced similar issue. Remove whitespace from your path. Rename Android Studio.app to AndroidStudio.app. That worked for me.

Upvotes: 13

Related Questions