gradlew buildRelease завершается с ошибкой java.lang.ClassNotFoundException: com.sun.tools.javac.util.Context - PullRequest
0 голосов
/ 18 мая 2018

Sidenote - этот пост похож (но не идентичен) на compileReleaseKotlin завершается неудачно с java.lang.ClassNotFoundException: com.sun.tools.javac.util.Context , но я думал, что сделаю мойсобственный пост с более подробной информацией о моей ситуации, чтобы получить максимально возможную обратную связь.Кроме того, я попробовал все решения в этом посте, и ни одно из них не сработало.

Я пытаюсь создать неподписанный релиз APK для моего приложения.Для этого я использую команду gradlew assembleRelease.

. Я получаю следующую ошибку:

Caught an exception trying to connect to Kotlin Daemon
java.lang.ClassNotFoundException: com.sun.tools.javac.util.Context
        at java.base/java.net.URLClassLoader.findClass(Unknown Source)
        at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
        at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Unknown Source)
        at org.jetbrains.kotlin.gradle.tasks.JarSearchingUtilKt.findToolsJ
ar(jarSearchingUtil.kt:79)
        at org.jetbrains.kotlin.compilerRunner.GradleCompilerEnvironment$t
oolsJar$2.invoke(GradleCompilerEnvironment.kt:20)
        at org.jetbrains.kotlin.compilerRunner.GradleCompilerEnvironment$t
oolsJar$2.invoke(GradleCompilerEnvironment.kt:14)
        at kotlin.SynchronizedLazyImpl.getValue(Lazy.kt:130)
        at org.jetbrains.kotlin.compilerRunner.GradleCompilerEnvironment.g
etToolsJar(GradleCompilerEnvironment.kt)
        at org.jetbrains.kotlin.compilerRunner.GradleCompilerEnvironment.g
etCompilerFullClasspath(GradleCompilerEnvironment.kt:23)
        at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.getDae
monConnection(GradleKotlinCompilerRunner.kt:336)
        at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compil
eWithDaemon(GradleKotlinCompilerRunner.kt:181)
        at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compil
eWithDaemonOrFallback(GradleKotlinCompilerRunner.kt:156)
        at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compil
eWithDaemonOrFallback(GradleKotlinCompilerRunner.kt:53)
        at org.jetbrains.kotlin.compilerRunner.KotlinCompilerRunner.runCom
piler(KotlinCompilerRunner.kt:127)
        at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runJvm
Compiler(GradleKotlinCompilerRunner.kt:108)
        at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$ko
tlin_gradle_plugin(Tasks.kt:378)
        at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$ko
tlin_gradle_plugin(Tasks.kt:253)
        at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute
(Tasks.kt:215)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0
(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(
Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.inv
oke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:7
3)
        at org.gradle.api.internal.project.taskfactory.IncrementalTaskActi
on.doExecute(IncrementalTaskAction.java:46)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.
execute(StandardTaskAction.java:39)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.
execute(StandardTaskAction.java:26)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecu
ter$1.run(ExecuteActionsTaskExecuter.java:121)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$Runn
ableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$Runn
ableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.exec
ute(DefaultBuildOperationExecutor.java:199)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(
DefaultBuildOperationExecutor.java:110)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecu
ter.executeAction(ExecuteActionsTaskExecuter.java:110)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecu
ter.executeActions(ExecuteActionsTaskExecuter.java:92)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecu
ter.execute(ExecuteActionsTaskExecuter.java:70)
        at org.gradle.api.internal.tasks.execution.OutputDirectoryCreating
TaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecute
r.execute(SkipUpToDateTaskExecuter.java:62)
        at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachin
gStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.
execute(ValidatingTaskExecuter.java:60)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTas
kExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExec
uter.execute(CleanupStaleOutputsExecuter.java:87)
        at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStat
eTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsEx
ecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.
execute(SkipOnlyIfTaskExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskEx
ecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecu
ter.execute(CatchExceptionTaskExecuter.java:34)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFi
ringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$Runn
ableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$Runn
ableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.exec
ute(DefaultBuildOperationExecutor.java:199)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(
DefaultBuildOperationExecutor.java:110)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFi
ringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFi
ringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExec
utorWorker.processTask(DefaultTaskPlanExecutor.java:123)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExec
utorWorker.access$200(DefaultTaskPlanExecutor.java:79)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExec
utorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExec
utorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute
(DefaultTaskExecutionPlan.java:626)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute
WithTask(DefaultTaskExecutionPlan.java:581)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExec
utorWorker.run(DefaultTaskPlanExecutor.java:98)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFai
lures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(Manage
dExecutorImpl.java:46)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unk
nown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Un
known Source)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadR
unnable.run(ThreadFactoryImpl.java:55)
        at java.base/java.lang.Thread.run(Unknown Source)
Could not perform incremental compilation: Could not connect to Kotlin com
pile daemon
Could not connect to kotlin daemon. Using fallback strategy.
e: java.lang.ClassNotFoundException: com.sun.tools.javac.util.Context
        at java.base/java.net.URLClassLoader.findClass(Unknown Source)
        at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
        at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Unknown Source)
        at org.jetbrains.kotlin.gradle.tasks.JarSearchingUtilKt.findToolsJ
ar(jarSearchingUtil.kt:79)
        at org.jetbrains.kotlin.compilerRunner.GradleCompilerEnvironment$t
oolsJar$2.invoke(GradleCompilerEnvironment.kt:20)
        at org.jetbrains.kotlin.compilerRunner.GradleCompilerEnvironment$t
oolsJar$2.invoke(GradleCompilerEnvironment.kt:14)
        at kotlin.SynchronizedLazyImpl.getValue(Lazy.kt:130)
        at org.jetbrains.kotlin.compilerRunner.GradleCompilerEnvironment.g
etToolsJar(GradleCompilerEnvironment.kt)
        at org.jetbrains.kotlin.compilerRunner.GradleCompilerEnvironment.g
etCompilerFullClasspath(GradleCompilerEnvironment.kt:23)
        at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compil
eOutOfProcess(GradleKotlinCompilerRunner.kt:303)
        at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compil
eWithDaemonOrFallback(GradleKotlinCompilerRunner.kt:171)
        at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compil
eWithDaemonOrFallback(GradleKotlinCompilerRunner.kt:53)
        at org.jetbrains.kotlin.compilerRunner.KotlinCompilerRunner.runCom
piler(KotlinCompilerRunner.kt:127)
        at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runJvm
Compiler(GradleKotlinCompilerRunner.kt:108)
        at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$ko
tlin_gradle_plugin(Tasks.kt:378)
        at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$ko
tlin_gradle_plugin(Tasks.kt:253)
        at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute
(Tasks.kt:215)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0
(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(
Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.inv
oke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:7
3)
        at org.gradle.api.internal.project.taskfactory.IncrementalTaskActi
on.doExecute(IncrementalTaskAction.java:46)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.
execute(StandardTaskAction.java:39)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.
execute(StandardTaskAction.java:26)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecu
ter$1.run(ExecuteActionsTaskExecuter.java:121)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$Runn
ableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$Runn
ableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.exec
ute(DefaultBuildOperationExecutor.java:199)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(
DefaultBuildOperationExecutor.java:110)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecu
ter.executeAction(ExecuteActionsTaskExecuter.java:110)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecu
ter.executeActions(ExecuteActionsTaskExecuter.java:92)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecu
ter.execute(ExecuteActionsTaskExecuter.java:70)
        at org.gradle.api.internal.tasks.execution.OutputDirectoryCreating
TaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecute
r.execute(SkipUpToDateTaskExecuter.java:62)
        at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachin
gStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.
execute(ValidatingTaskExecuter.java:60)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTas
kExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExec
uter.execute(CleanupStaleOutputsExecuter.java:87)
        at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStat
eTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsEx
ecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.
execute(SkipOnlyIfTaskExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskEx
ecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecu
ter.execute(CatchExceptionTaskExecuter.java:34)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFi
ringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$Runn
ableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$Runn
ableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.exec
ute(DefaultBuildOperationExecutor.java:199)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(
DefaultBuildOperationExecutor.java:110)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFi
ringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFi
ringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExec
utorWorker.processTask(DefaultTaskPlanExecutor.java:123)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExec
utorWorker.access$200(DefaultTaskPlanExecutor.java:79)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExec
utorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExec
utorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute
(DefaultTaskExecutionPlan.java:626)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute
WithTask(DefaultTaskExecutionPlan.java:581)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExec
utorWorker.run(DefaultTaskPlanExecutor.java:98)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFai
lures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(Manage
dExecutorImpl.java:46)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unk
nown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Un
known Source)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadR
unnable.run(ThreadFactoryImpl.java:55)
        at java.base/java.lang.Thread.run(Unknown Source)

Вот еще немного информации о моей текущей ситуации:

I 'm с использованием Windows 10.

Это результат gradlew assembleRelease --scan.Он содержит много подробной информации, которая может быть полезна для отладки.

https://scans.gradle.com/s/sohrhovsc676e/

В Android Studio я перешел в «Файл -> Структура проекта» и изменил свое местоположение JDK с

"C: \ Program Files \ Android \ Android Studio \ jre" (встроенный JDK)

до

"C: \ Program Files \ Java \ jdk1.8.0_172"(JDK 8), который я получил от здесь .

Это не решило проблему.

Я также добавил «C: \ Program Files \ Java \ jdk1.8.0_172 \ bin» в переменную System Path.

Я также загрузил свой проект на Github, если кому-то нужно его увидеть.https://github.com/vedantroy/recyclerview-test

Кроме того, ранее я пытался заменить implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" на implementation"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version", но это тоже не сработало.

Редактировать 1 -

Я пытался переключить мойСоздайте Variant для «выпуска», а затем создайте APK, и это, похоже, сработало.Однако я не уверен, что это даст тот же результат, что и gradlew assembleRelease

1 Ответ

0 голосов
/ 18 июля 2018

В моем случае это начало происходить после обновления Java.Оказывается, JRE был обновлен, но JDK не был.

Попробуйте: установите новое обновление JDK, удалите старые версии и снова откройте все сеансы оболочки / ps / cmd / windows.Может быть необходимо убить существующих демонов Gradle, но он должен быть достаточно умен, чтобы не использовать их повторно.Попробуйте еще раз!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...