Exception in thread "main" java.lang.NoClassDefFoundError: junit / textui / ResultPrinter After upgrading to Yosemite

I recently upgraded my system from Mavericks (OSX) to Yosemite. I use to be able to right-click on a test and run it. Now i get an 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 can also be related to the fact that when I click on the open Android Studio icon in my dock, I get an error message, but the JVM was not found, but I can open it through Terminal without problems.

This is the same as the new studio project for Android, which is trying to launch the default application.

+6
java android android-studio junit
Jan 11 '15 at 17:31
source share
2 answers

So two things

Firstly, if you try to open the Android Studio version on Yosemite, and it says: โ€œNo JVM foundโ€, you need to install java 6 for osx, here Android requires java 1.6, not java 1.6 +.

Secondly, the exception that I found was caused by the fact that he was trying to run JUnit, as if I wanted to run the standard java console instead of Android.

Do not use Java test containing black color with arrows, use unit tests in Android Tests and remove all use of JUnit configuration.

enter image description here

Your configuration should look like this, then you can right-click on single tests and run them as usual.

enter image description here

+20
Jan 11 '15 at 22:32
source share

Starting with the release of Android Studio 1.1.0 (February 18, 2015), it is now possible to run standard JUnit tests in Android Studio on the local JVM until the test code calls the Android API. Please follow the instructions in this manual for more information.

+5
Mar 12 '15 at
source share



All Articles