Kotlin中的NotImplementedError,没有任何TODO。

huangapple go评论72阅读模式
英文:

Kotlin NotImplementedError without any TODO

问题

我的 Kotlin 项目抛出了 kotlin.NotImplementedErrorExecution failed for task ':app:compileDebugKotlin'。它不包含任何 TODO。

完整的堆栈跟踪 -

kotlin.NotImplementedError: 操作尚未实现:尚未实现
	at org.jetbrains.kotlin.ir.descriptors.IrBasedFieldDescriptor.getContextReceiverParameters(IrBasedDescriptors.kt:1067)
	// 其他堆栈信息...
Caused by: org.gradle.api.GradleException: 内部编译器错误。请查看日志以获取更多详细信息
	// 其他堆栈信息...

我尝试了以下方法:

  • 清理和重新构建
  • 使缓存无效并重新启动
  • 注释掉最近添加的代码
  • 在 Android Studio 中修复 IDE
  • 从 GitHub 中删除项目,然后重新加载

但都没有解决这个问题。

该项目 - github

英文:

My kotlin project throws kotlin.NotImplementedError and Execution failed for task ':app:compileDebugKotlin'. It doesn't contain any TODO.

Full stack trace -

kotlin.NotImplementedError: An operation is not implemented: Not yet implemented
at org.jetbrains.kotlin.ir.descriptors.IrBasedFieldDescriptor.getContextReceiverParameters(IrBasedDescriptors.kt:1067)
at org.jetbrains.kotlin.renderer.DescriptorRendererImpl.renderProperty(DescriptorRendererImpl.kt:936)
at org.jetbrains.kotlin.renderer.DescriptorRendererImpl.access$renderProperty(DescriptorRendererImpl.kt:32)
at org.jetbrains.kotlin.renderer.DescriptorRendererImpl$RenderDeclarationDescriptorVisitor.visitPropertyDescriptor(DescriptorRendererImpl.kt:1126)
at org.jetbrains.kotlin.renderer.DescriptorRendererImpl$RenderDeclarationDescriptorVisitor.visitPropertyDescriptor(DescriptorRendererImpl.kt:1116)
at org.jetbrains.kotlin.ir.descriptors.IrBasedFieldDescriptor.accept(IrBasedDescriptors.kt:1073)
at org.jetbrains.kotlin.renderer.DescriptorRendererImpl.render(DescriptorRendererImpl.kt:601)
at org.jetbrains.kotlin.resolve.MemberComparator.compare(MemberComparator.java:221)
at org.jetbrains.kotlin.resolve.MemberComparator.compare(MemberComparator.java:35)
at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
at java.base/java.util.TimSort.sort(TimSort.java:220)
at java.base/java.util.Arrays.sort(Arrays.java:1441)
at kotlin.collections.ArraysKt___ArraysJvmKt.sortWith(_ArraysJvm.kt:2557)
at kotlin.collections.CollectionsKt___CollectionsKt.sortedWith(_Collections.kt:1075)
at org.jetbrains.kotlin.resolve.jvm.diagnostics.KtDefaultJvmErrorMessages$CONFLICTING_JVM_DECLARATIONS_DATA$1.invoke(JvmBackendErrors.kt:49)
at org.jetbrains.kotlin.resolve.jvm.diagnostics.KtDefaultJvmErrorMessages$CONFLICTING_JVM_DECLARATIONS_DATA$1.invoke(JvmBackendErrors.kt:45)
at org.jetbrains.kotlin.diagnostics.rendering.DiagnosticParameterRendererKt$Renderer$1.render(DiagnosticParameterRenderer.kt:30)
at org.jetbrains.kotlin.diagnostics.rendering.ContextIndependentParameterRenderer$DefaultImpls.render(DiagnosticParameterRenderer.kt:24)
at org.jetbrains.kotlin.diagnostics.rendering.DiagnosticParameterRendererKt$Renderer$1.render(DiagnosticParameterRenderer.kt:29)
at org.jetbrains.kotlin.diagnostics.rendering.DiagnosticParameterRendererKt.renderParameter(DiagnosticParameterRenderer.kt:38)
at org.jetbrains.kotlin.diagnostics.KtDiagnosticWithParameters1Renderer.renderParameters(KtDiagnosticRenderer.kt:48)
at org.jetbrains.kotlin.diagnostics.AbstractKtDiagnosticWithParametersRenderer.render(KtDiagnosticRenderer.kt:36)
at org.jetbrains.kotlin.cli.common.fir.FirDiagnosticsCompilerResultsReporter.reportDiagnosticToMessageCollector(FirDiagnosticsCompilerResultsReporter.kt:101)
at org.jetbrains.kotlin.cli.common.fir.FirDiagnosticsCompilerResultsReporter.access$reportDiagnosticToMessageCollector(FirDiagnosticsCompilerResultsReporter.kt:19)
at org.jetbrains.kotlin.cli.common.fir.FirDiagnosticsCompilerResultsReporter$reportToMessageCollector$1.invoke(FirDiagnosticsCompilerResultsReporter.kt:26)
at org.jetbrains.kotlin.cli.common.fir.FirDiagnosticsCompilerResultsReporter$reportToMessageCollector$1.invoke(FirDiagnosticsCompilerResultsReporter.kt:19)
at org.jetbrains.kotlin.cli.common.fir.FirDiagnosticsCompilerResultsReporter.reportByFile(FirDiagnosticsCompilerResultsReporter.kt:68)
at org.jetbrains.kotlin.cli.common.fir.FirDiagnosticsCompilerResultsReporter.reportToMessageCollector(FirDiagnosticsCompilerResultsReporter.kt:25)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.runCodegen(KotlinToJVMBytecodeCompiler.kt:375)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:134)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:58)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:158)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:53)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:99)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:47)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:475)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:125)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:373)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally$default(IncrementalCompilerRunner.kt:318)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.rebuild(IncrementalCompilerRunner.kt:114)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:207)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:79)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:625)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:101)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1746)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)

and,

Caused by: org.gradle.api.GradleException: Internal compiler error. See log for more details
at org.jetbrains.kotlin.gradle.tasks.TasksUtilsKt.throwGradleExceptionIfError(tasksUtils.kt:23)
at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.run(GradleKotlinCompilerWork.kt:129)
at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction.execute(GradleCompilerRunnerWithWorkers.kt:79)
at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:66)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:62)
at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:100)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$execute$0(NoIsolationWorkerFactory.java:62)
at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:59)
at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$2(DefaultWorkerExecutor.java:205)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:187)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.access$700(DefaultConditionalExecutionQueue.java:120)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner$1.run(DefaultConditionalExecutionQueue.java:162)
at org.gradle.internal.Factories$1.create(Factories.java:31)
at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:249)
at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:109)
at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:114)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:157)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:126)

What I tried :

  • Clean and Rebuild
  • Invalidate caches and restart
  • Commenting out latest added codes
  • Repair IDE in Android Studio
  • Deleting the project and loading from github again

And none of this solved it.

The project - github

答案1

得分: 1

原来问题是因为我在ClientService类的全局变量中两次声明了lateinit var clientConfig: ClientConfig,同时还在同一个类中作为伴生对象声明了它,而Android Studio没有指出这个问题。

英文:

Turns out, it was caused because I had

lateinit var clientConfig: ClientConfig

twice... as a global variable inside the class ClientService and also as a companion object in the same class and Android Studio was unable to point that out.

huangapple
  • 本文由 发表于 2023年2月14日 20:56:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/75448159.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定