Android Studio 3.0 Kotlin无法正常工作

时间:2017-11-05 22:17:25

标签: android kotlin android-studio-3.0

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

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 s.r.o 
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的错误了,不过我想知道是否有其他人已经通过这个并找到了一个解决方法,我可以尝试在我的结束时暂时克服这个错误,直到它由JetBrains解决。

2 个答案:

答案 0 :(得分:1)

您报告的这个错误几乎在一年前就解决了,它影响了旧版本的Kotlin插件:https://youtrack.jetbrains.com/issue/KT-12264

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

答案 1 :(得分:1)

问题发生了,因为我将app / src / main / java重命名为app / src / main / kotlin(因为即使项目设置为从头开始包含kotlin支持,Android Studio也不会这样做)和后者未标记为源文件夹。将其标记为源文件夹后,问题立即得到解决。