I recently updated my system from Mavericks (OSX) to Yosemite. I use to be able to right click on a test and run it. Now I get the exception
/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/bin/java -ea -Didea.launcher.port=7541 "-Didea.launcher.bin.path=/Applications/Android Studio.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Applications/Android Studio.app/Contents/lib/idea_rt.jar:/Applications/Android Studio.app/Contents/plugins/junit/lib/junit-rt.jar:/Users/michael.cameron/Code/Android/sdk/platforms/android-21/android.jar:/Users/michael.cameron/Code/Android/sdk/platforms/android-21/data/res:/Users/michael.cameron/Code/Android/darxstudios/TheChefsCodex/app/build/intermediates/classes/debug:/Users/michael.cameron/Code/Android/darxstudios/TheChefsCodex/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/classes.jar:/Users/michael.cameron/Code/Android/darxstudios/TheChefsCodex/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/res:/Users/michael.cameron/Code/Android/darxstudios/TheChefsCodex/app/libs/ParseCrashReporting-1.8.0.jar:/Users/michael.cameron/Code/Android/sdk/extras/android/m2repository/com/android/support/support-annotations/21.0.3/support-annotations-21.0.3.jar:/Users/michael.cameron/Code/Android/darxstudios/TheChefsCodex/app/build/intermediates/exploded-aar/com.android.support/support-v4/21.0.3/res:/Users/michael.cameron/Code/Android/darxstudios/TheChefsCodex/app/build/intermediates/exploded-aar/com.android.support/support-v4/21.0.3/classes.jar:/Users/michael.cameron/Code/Android/darxstudios/TheChefsCodex/app/build/intermediates/exploded-aar/com.android.support/support-v4/21.0.3/libs/internal_impl-21.0.3.jar:/Users/michael.cameron/Code/Android/darxstudios/TheChefsCodex/app/libs/Parse-1.8.0.jar:/Users/michael.cameron/.gradle/caches/modules-2/files-2.1/com.parse.bolts/bolts-android/1.1.4/129874135e6081269ace2312092031558865de12/bolts-android-1.1.4.jar:/Users/michael.cameron/Code/Android/darxstudios/TheChefsCodex/app/libs/bolts-android-1.1.4.jar" com.intellij.rt.execution.application.AppMain com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 com.darxstudios.thechefscodex.ApplicationTest
Exception in thread "main" java.lang.NoClassDefFoundError: junit/textui/ResultPrinter
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:191)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:116)
Caused by: java.lang.ClassNotFoundException: junit.textui.ResultPrinter
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 3 more
it may also be related to when i tap the open Android Studio icon in my Dock i get the error no JVM was found but i can open it via Terminal no problem.
This is the same as a brand new android studio project with the default applicationTest trying to run.
So two things
First, if you try to open Android Studio on Yosemite upgrade and it says "No JVM found" you need to install the java 6 for osx here as Android requires java 1.6 and not java 1.6+.
Second, The Exception I found was caused because it was trying to run JUnit as if I wanted to run through java standard console instead of with Android.
Do not use the Java test that contains a black with arrows, use the unit tests within a Android Tests and delete all uses of the JUnit configuration.
Your configuration should look like this, then you can right click on single tests and run them like normal.
As of the release of Android Studio 1.1.0 (on Feb 18 2015), it is now possible to run standard JUnit tests in Android Studio on local JVM for as long as the code under test isn't calling Android API. Please follow the instructions in this guide for more info.
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