"Class JavaLaunchHelper is implemented in both"... "which one is undefined" error in Android Studio 2.2.2

Has anyone tried to use OF 0.9.5 with the latest version of Android Studio (2.2.2)? Now the IDE comes with its own JDK, and that is giving me trouble to compile the examples. As far as I can understand, the compiler is telling me that the JDK path is defined in two places and I’m not sure how to fix that.

"/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java" -    agentlib:jdwp=transport=dt_socket,address=127.0.0.1:52851,suspend=y,server=n -ea -javaagent:/Users/poliveira/Library/Caches/AndroidStudio2.2/groovyHotSwap/gragent.jar -Didea.junit.sm_runner -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/poliveira/Library/Android/sdk/platforms/android-22/data/res:/Users/poliveira/Documents/Programming/Android/of_v0.9.5_android_release/examples/android/androidCameraExample/build/intermediates/classes/debug:/Users/poliveira/Documents/Programming/Android/of_v0.9.5_android_release/addons/ofxAndroid/ofAndroidLib/build/intermediates/classes/debug:/Users/poliveira/Documents/Programming/Android/of_v0.9.5_android_release/examples/android/androidCameraExample/build/intermediates/sourceFolderJavaResources/test/debug:/Users/poliveira/Documents/Programming/Android/of_v0.9.5_android_release/examples/android/androidCameraExample/build/intermediates/sourceFolderJavaResources/debug:/Users/poliveira/Documents/Programming/Android/of_v0.9.5_android_release/addons/ofxAndroid/ofAndroidLib/build/intermediates/sourceFolderJavaResources/debug:/Users/poliveira/Documents/Programming/Android/of_v0.9.5_android_release/examples/android/androidCameraExample/build/generated/mockable-android-22.jar" com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 @w@/private/var/folders/_1/b6c1c1pd23q6k2001hwznlk40000gn/T/idea_working_dirs_junit1.tmp @/private/var/folders/_1/b6c1c1pd23q6k2001hwznlk40000gn/T/idea_junit1.tmp -socket52850
objc[15552]: Class JavaLaunchHelper is implemented in both /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java (0x103fb14c0) and /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/jre/lib/libinstrument.dylib (0x1040b64e0). One of the two will be used. Which one is undefined.
Connected to the target VM, address: '127.0.0.1:52851', transport: 'socket'
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: junit/textui/ResultPrinter
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
	at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
	at java.lang.Class.getMethod0(Class.java:3018)
	at java.lang.Class.getMethod(Class.java:1784)
	at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
	at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: junit.textui.ResultPrinter
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 7 more
Disconnected from the target VM, address: '127.0.0.1:52851', transport: 'socket'

Process finished with exit code 1

I’m trying to define the JDK myself, but for some reason the Android Studio won’t let me downgrade to JDK 1.7.

Any lights here are much appreciated.

It was a NDK issue, apparently, ended up downloading the r10e as indicated in the install instructions and it seems to compile fine. Also, in the project’s build.gradle, had to change these lines:

assembleDebug.dependsOn(":openFrameworksProject:compileDebugOF")
assembleRelease.dependsOn(":openFrameworksProject:compileReleaseOF")

To this:

tasks.whenTaskAdded { task ->
    if(task.name == 'assembleRelease'){
        task.dependsOn ':openFrameworksProject:compileReleaseOF'
    }
}

tasks.whenTaskAdded { task ->
    if(task.name == 'assembleDebug'){
        task.dependsOn ':openFrameworksProject:compileDebugOF'
    }
}
1 Like