UnsupportedJavaRuntimeException.assertUsingVersion in Android Studio

‹ Against Empathy | Kappa Architecture ›

After upgrading Android Studio to version 2.3, you may get:

[ 23178] WARN - nal.AbstractExternalSystemTask - org.gradle.internal.jvm.UnsupportedJavaRuntimeException.assertUsingVersion(Ljava/lang/String;Lorg/gradle/api/JavaVersion;)V
java.lang.NoSuchMethodError: org.gradle.internal.jvm.UnsupportedJavaRuntimeException.assertUsingVersion(Ljava/lang/String;Lorg/gradle/api/JavaVersion;)V
    at org.gradle.tooling.internal.consumer.ConnectorServices.checkJavaVersion(ConnectorServices.java:57)
    at org.gradle.tooling.internal.consumer.ConnectorServices.createConnector(ConnectorServices.java:35)
    at org.gradle.tooling.GradleConnector.newConnector(GradleConnector.java:85)
    at org.jetbrains.plugins.gradle.service.execution.GradleExecutionHelper.getConnection(GradleExecutionHelper.java:333)
    at org.jetbrains.plugins.gradle.service.execution.GradleExecutionHelper.execute(GradleExecutionHelper.java:222)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:112)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:72)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.lambda$resolveProjectInfo$0(RemoteExternalSystemProjectResolverImpl.java:37)
    at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:59)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:37)
    at com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:49)
    at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:51)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:138)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:124)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3.execute(ExternalSystemUtil.java:415)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$5.run(ExternalSystemUtil.java:494)
    at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:635)
    at com.intellij.openapi.progress.impl.CoreProgressManager$3.run(CoreProgressManager.java:170)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:494)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:443)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:155)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$1.run(ProgressManagerImpl.java:128)
    at com.intellij.openapi.application.impl.ApplicationImpl$2.run(ApplicationImpl.java:307)
    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)

This is due to Android Studio 2.3.0+ requiring Gradle 3.3+ and can be seen in the source code, where UnsupportedJavaRuntimeException in 3.3 has an assertUsingVersion method and the 2.14.1 version of UnsupportedJavaRuntimeException does not.

In my case, it was caused by the existence of a /opt/android-studio/gradle/gradle-2.14.1 directory -- deleting the entire android studio installation and unzipping it from scratch seemed to resolve the issue.

However, to upgrade a single project to Gradle to 3.3, you can go into File : Project Structure : Project in the GUI, or you can edit gradle/wrapper/gradle-wrapper.properties and change distributionUrl to look like:

distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

Comments

 deleting the entire android studio installation and unzipping it from scratch seemed to resolve the issue : Prefect. I did the same to get it working

Subscribe to All Posts - Wesley Tanaka