Android Studio 3.0 Kotlin无法正常工作

我最近安装了Android Studio 3.0,并使用Kotlin开始了一个新项目。 自开始项目以来,突出显示和代码完成的kotlin插件一直在正常工作。 不过,几天前我从开始这个项目开始就第一次关闭了Android Studio,现在当我重新打开它时,代码完成和突出显示已经停止工作,Android Studio向我显示以下exception:

2017-11-05 19:38:03,424 [ thread 19] ERROR - on.CompletionProgressIndicator - Resolver for 'completion/highlighting in org.jetbrains.kotlin.idea.caches.resolve.NotUnderContentRootModuleInfo@3a2816ac for files GameMainActivity.kt for platform JVM' does not know how to resolve ModuleProductionSourceInfo(module=Module: 'app') java.lang.AssertionError: Resolver for 'completion/highlighting in org.jetbrains.kotlin.idea.caches.resolve.NotUnderContentRootModuleInfo@3a2816ac for files GameMainActivity.kt for platform JVM' does not know how to resolve ModuleProductionSourceInfo(module=Module: 'app') at org.jetbrains.kotlin.analyzer.ResolverForProjectImpl.descriptorForModule(AnalyzerFacade.kt:168) at org.jetbrains.kotlin.analyzer.ResolverForProjectImpl.descriptorForModule(AnalyzerFacade.kt:77) at org.jetbrains.kotlin.analyzer.ResolverForProject.resolverForModule(AnalyzerFacade.kt:56) at org.jetbrains.kotlin.idea.caches.resolve.ProjectResolutionFacade.resolverForModuleInfo(ProjectResolutionFacade.kt:73) at org.jetbrains.kotlin.idea.caches.resolve.ResolutionFacadeImpl.tryGetFrontendService(ResolutionFacadeImpl.kt:87) at org.jetbrains.kotlin.idea.caches.resolve.JavaResolutionUtils.getJavaDescriptorResolver(JavaResolveExtension.kt:109) at org.jetbrains.kotlin.idea.caches.resolve.JavaResolutionUtils.getJavaClassDescriptor(JavaResolveExtension.kt:55) at org.jetbrains.kotlin.idea.caches.resolve.JavaResolutionUtils.resolveToDescriptor(JavaResolveExtension.kt:103) at org.jetbrains.kotlin.idea.caches.resolve.JavaResolutionUtils.resolveToDescriptor$default(JavaResolveExtension.kt:95) at org.jetbrains.kotlin.idea.completion.BasicCompletionSession$ALL$1$completeNonImported$6.invoke(BasicCompletionSession.kt:379) at org.jetbrains.kotlin.idea.completion.BasicCompletionSession$ALL$1$completeNonImported$6.invoke(BasicCompletionSession.kt:182) at org.jetbrains.kotlin.idea.completion.AllClassesCompletion$addAdaptedJavaCompletion$1.consume(AllClassesCompletion.kt:100) at org.jetbrains.kotlin.idea.completion.AllClassesCompletion$addAdaptedJavaCompletion$1.consume(AllClassesCompletion.kt:41) at com.intellij.codeInsight.completion.LimitedAccessibleClassPreprocessor.process(LimitedAccessibleClassPreprocessor.java:80) at com.intellij.codeInsight.completion.LimitedAccessibleClassPreprocessor.process(LimitedAccessibleClassPreprocessor.java:32) at com.intellij.psi.impl.search.AllClassesSearchExecutor.processClassesByNames(AllClassesSearchExecutor.java:84) at com.intellij.codeInsight.completion.AllClassesGetter.processJavaClasses(AllClassesGetter.java:157) at com.intellij.codeInsight.completion.AllClassesGetter.processJavaClasses(AllClassesGetter.java:143) at org.jetbrains.kotlin.idea.completion.AllClassesCompletion.addAdaptedJavaCompletion(AllClassesCompletion.kt:89) at org.jetbrains.kotlin.idea.completion.AllClassesCompletion.collect(AllClassesCompletion.kt:72) at org.jetbrains.kotlin.idea.completion.BasicCompletionSession$ALL$1.completeNonImported(BasicCompletionSession.kt:379) at org.jetbrains.kotlin.idea.completion.BasicCompletionSession$ALL$1.access$completeNonImported(BasicCompletionSession.kt:182) at org.jetbrains.kotlin.idea.completion.BasicCompletionSession$ALL$1$doComplete$4.invoke(BasicCompletionSession.kt:304) at org.jetbrains.kotlin.idea.completion.BasicCompletionSession$ALL$1$doComplete$4.invoke(BasicCompletionSession.kt:182) at org.jetbrains.kotlin.idea.completion.CompletionSession.withContextVariablesProvider(CompletionSession.kt:385) at org.jetbrains.kotlin.idea.completion.BasicCompletionSession$ALL$1.doComplete(BasicCompletionSession.kt:274) at org.jetbrains.kotlin.idea.completion.BasicCompletionSession.doComplete(BasicCompletionSession.kt:154) at org.jetbrains.kotlin.idea.completion.CompletionSession._complete(CompletionSession.kt:233) at org.jetbrains.kotlin.idea.completion.CompletionSession.complete(CompletionSession.kt:208) at org.jetbrains.kotlin.idea.completion.KotlinCompletionContributor.doComplete(KotlinCompletionContributor.kt:301) at org.jetbrains.kotlin.idea.completion.KotlinCompletionContributor.doComplete$default(KotlinCompletionContributor.kt:262) at org.jetbrains.kotlin.idea.completion.KotlinCompletionContributor.performCompletion(KotlinCompletionContributor.kt:255) at org.jetbrains.kotlin.idea.completion.KotlinCompletionContributor.access$performCompletion(KotlinCompletionContributor.kt:47) at org.jetbrains.kotlin.idea.completion.KotlinCompletionContributor$provider$1.addCompletions(KotlinCompletionContributor.kt:58) at com.intellij.codeInsight.completion.CompletionProvider.addCompletionVariants(CompletionProvider.java:36) at com.intellij.codeInsight.completion.CompletionContributor.fillCompletionVariants(CompletionContributor.java:151) at com.intellij.codeInsight.completion.CompletionService.getVariantsFromContributors(CompletionService.java:81) at com.intellij.codeInsight.completion.CompletionResultSet.runRemainingContributors(CompletionResultSet.java:138) at com.intellij.codeInsight.completion.CompletionResultSet.runRemainingContributors(CompletionResultSet.java:131) at com.intellij.codeInsight.template.impl.LiveTemplateCompletionContributor$2.addCompletions(LiveTemplateCompletionContributor.java:88) at com.intellij.codeInsight.completion.CompletionProvider.addCompletionVariants(CompletionProvider.java:36) at com.intellij.codeInsight.completion.CompletionContributor.fillCompletionVariants(CompletionContributor.java:151) at com.intellij.codeInsight.completion.CompletionService.getVariantsFromContributors(CompletionService.java:81) at com.intellij.codeInsight.completion.CompletionService.performCompletion(CompletionService.java:110) at com.intellij.codeInsight.completion.CompletionProgressIndicator.calculateItems(CompletionProgressIndicator.java:831) at com.intellij.codeInsight.completion.CompletionProgressIndicator.access$600(CompletionProgressIndicator.java:93) at com.intellij.codeInsight.completion.CompletionProgressIndicator$1CalculateItems.run(CompletionProgressIndicator.java:813) at com.intellij.codeInsight.completion.AsyncCompletion.lambda$null$0(CompletionThreading.java:108) at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:931) at com.intellij.codeInsight.completion.AsyncCompletion.lambda$null$1(CompletionThreading.java:105) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:176) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:556) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:501) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:66) at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:163) at com.intellij.codeInsight.completion.AsyncCompletion.lambda$startThread$2(CompletionThreading.java:103) at com.intellij.openapi.application.impl.ApplicationImpl$2.run(ApplicationImpl.java:334) 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) 2017-11-05 19:38:03,425 [ thread 19] ERROR - on.CompletionProgressIndicator - Android Studio 3.0 Build #AI-171.4408382 2017-11-05 19:38:03,425 [ thread 19] ERROR - on.CompletionProgressIndicator - JDK: 1.8.0_152-release 2017-11-05 19:38:03,425 [ thread 19] ERROR - on.CompletionProgressIndicator - VM: OpenJDK 64-Bit Server VM 2017-11-05 19:38:03,425 [ thread 19] ERROR - on.CompletionProgressIndicator - Vendor: JetBrains sro 2017-11-05 19:38:03,425 [ thread 19] ERROR - on.CompletionProgressIndicator - OS: Mac OS X 2017-11-05 19:38:03,425 [ thread 19] ERROR - on.CompletionProgressIndicator - Last Action: EditorBackSpace 2017-11-05 19:38:04,922 [ thread 19] ERROR - on.CompletionProgressIndicator - Resolver for 'completion/highlighting in org.jetbrains.kotlin.idea.caches.resolve.NotUnderContentRootModuleInfo@3a2816ac for files GameMainActivity.kt for platform JVM' does not know how to resolve ModuleProductionSourceInfo(module=Module: 'app') 

我已经提出了一个已经从Android Studio中发送到JetBrains的错误,但是我想知道是否有其他人已经经历了这个问题,并且find了一个解决方法,我可以尝试在我的端点暂时解决这个错误,直到解决由JetBrains。

2 Solutions collect form web for “Android Studio 3.0 Kotlin无法正常工作”

你正在报告的这个bug在一年前已经被解决了,它影响到了一个老版本的Kotlin插件: https : //youtrack.jetbrains.com/issue/KT-12264

尝试使AS缓存无效并重新启动(文件 – >无效缓存/重新启动 – >使缓存失效并重新启动)。

发生这个问题是因为我将app / src / main / java重命名为app / src / main / kotlin(因为Android Studio本身并不这样做,即使项目设置为从头开始包含kotlin支持),而后者没有标记作为源文件夹。 一旦它被标记为源文件夹,问题立即解决。

  • Android Anko警报与自定义视图错误(Kotlin)
  • 未解决的参考DaggerApplicationComponent
  • IncompatibleClassChangeError:类'java.lang.VirtualMachineError'没有实现接口'java.lang.CharSequence'
  • Kotlin库项目失败的解决方案:[Lkotlin / reflect / KProperty
  • 连接moshi到Android Studio(Kotlin)
  • 代码A和代码B在Kotlin有什么不同?
  • 将源文件附加到kotlin库项目不会显示在AS中
  • Kotlin kotlinClass.class.getName()不能返回包名,而只能返回简单的类名
  • 燃料,Kotlin,Gson,预计BEGIN_ARRAY,但在BEGIN_OBJECT第1行
  • Java / Android / Kotlin:关于私人领域的反思和调用公共方法
  • Kotlin Activity不包含在APK中
  • Kotlin language will be the best programming language for Android.