美文网首页
AndroidStudio Kotlin Analysis 卡住

AndroidStudio Kotlin Analysis 卡住

作者: 笨鱼天阳 | 来源:发表于2021-12-21 02:38 被阅读0次

    Android Studio

    原文:https://blog.csdn.net/CrazyApes/article/details/122043395

    前言

    最近更新完 Android Studio 之后,发现莫名其妙的经常很卡。通过任务管理器查看Studio竟然一直持续CPU使用率在95%以上, What the Fk!!

    什么情况啊!

    首先确认,当前Studio没有运行下载,没有打包,没有开模拟器,也没什么正在执行的任务。
    最后找了半天发现 Analysis.. 在持续运行。。。
    很疯狂的运行。。。

    repeat.gif

    Android Studio 版本

    Android Studio.png

    Android Studio Arctic Fox | 2020.3.1 Patch 3
    Build #AI-203.7717.56.2031.7784292, built on October 1, 2021
    Runtime version: 11.0.10+0-b96-7249189 amd64
    VM: OpenJDK 64-Bit Server VM by Oracle Corporation
    Windows 10 10.0
    GC: G1 Young Generation, G1 Old Generation
    Memory: 1280M
    Cores: 4
    Registry: external.system.auto.import.disabled=true
    Non-Bundled Plugins: GsonFormatPlus, Dart, org.jetbrains.kotlin, io.flutter

    Log

    目测肯定是有问题啊。
    咱们先找Log日志看看。

    • 日志获取方式
      Help >> Show Log in Explorer

    • 日志路径
      C:\Users\CrazyApes\AppData\Local\Google\AndroidStudio2020.3\log\idea.log

    错误日志如下

    
    2021-12-20 14:45:41,225 [ 324567]  ERROR - aemon.impl.PassExecutorService - Android Studio Arctic Fox | 2020.3.1 Patch 3  Build #AI-203.7717.56.2031.7784292 
    2021-12-20 14:45:41,225 [ 324567]  ERROR - aemon.impl.PassExecutorService - JDK: 11.0.10; VM: OpenJDK 64-Bit Server VM; Vendor: Oracle Corporation 
    2021-12-20 14:45:41,225 [ 324567]  ERROR - aemon.impl.PassExecutorService - OS: Windows 10 
    2021-12-20 14:45:41,226 [ 324568]  ERROR - aemon.impl.PassExecutorService - Plugin to blame: Kotlin version: 203-1.6.10-release-923-AS7717.8 
    2021-12-20 14:45:41,227 [ 324569]  ERROR - aemon.impl.PassExecutorService - Last Action: EditorEnter 
    2021-12-20 14:45:42,160 [ 325502]  ERROR - aemon.impl.PassExecutorService - ContentElementType: ManifestFile; file: ManifestFile:MANIFEST.MF
        Boolean.TRUE.equals(getUserData(BUILDING_STUB)) = false
        getTreeElement() = Element(ManifestFile)
        vFile instanceof VirtualFileWithId = true
        StubUpdatingIndex.canHaveStub(vFile) = false 
    java.lang.AssertionError: ContentElementType: ManifestFile; file: ManifestFile:MANIFEST.MF
        Boolean.TRUE.equals(getUserData(BUILDING_STUB)) = false
        getTreeElement() = Element(ManifestFile)
        vFile instanceof VirtualFileWithId = true
        StubUpdatingIndex.canHaveStub(vFile) = false
        at com.intellij.psi.impl.source.PsiFileImpl.calcStubTree(PsiFileImpl.java:976)
        at com.intellij.psi.stubs.StubProcessingHelperBase.checkType(StubProcessingHelperBase.java:91)
        at com.intellij.psi.stubs.StubProcessingHelperBase.processStubsInFile(StubProcessingHelperBase.java:61)
        at com.intellij.psi.stubs.StubIndexImpl.lambda$processElements$2(StubIndexImpl.java:291)
        at com.intellij.psi.stubs.StubIndexImpl.processElements(StubIndexImpl.java:327)
        at com.intellij.psi.stubs.StubIndex.getElements(StubIndex.java:105)
        at com.intellij.psi.stubs.StubIndex.getElements(StubIndex.java:93)
        at org.jetbrains.kotlin.idea.stubindex.KotlinFileFacadeClassByPackageIndex.get(KotlinFileFacadeClassByPackageIndex.kt:19)
        at org.jetbrains.kotlin.idea.caches.resolve.IDEKotlinAsJavaSupport$getFacadeClassesInPackage$facadeFilesInPackage$1.invoke(IDEKotlinAsJavaSupport.kt:55)
        at org.jetbrains.kotlin.idea.caches.resolve.IDEKotlinAsJavaSupport$getFacadeClassesInPackage$facadeFilesInPackage$1.invoke(IDEKotlinAsJavaSupport.kt:53)
        at org.jetbrains.kotlin.idea.util.application.ApplicationUtilsKt.runReadAction$lambda-0(ApplicationUtils.kt:17)
        at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:877)
        at org.jetbrains.kotlin.idea.util.application.ApplicationUtilsKt.runReadAction(ApplicationUtils.kt:17)
        at org.jetbrains.kotlin.idea.caches.resolve.IDEKotlinAsJavaSupport.getFacadeClassesInPackage(IDEKotlinAsJavaSupport.kt:53)
        at org.jetbrains.kotlin.asJava.LightClassUtilsKt.findFacadeClass(lightClassUtils.kt:58)
        at org.jetbrains.uast.kotlin.KotlinInternalUastUtilsKt.getContainingLightClass(kotlinInternalUastUtils.kt:89)
        at org.jetbrains.uast.kotlin.KotlinConverter.getLightClassForFakeMethod(KotlinConverter.kt:479)
        at org.jetbrains.uast.kotlin.KotlinConverter.convertDeclaration(KotlinConverter.kt:428)
        at org.jetbrains.uast.kotlin.KotlinConverter.convertDeclarationOrElement(KotlinConverter.kt:488)
        at org.jetbrains.uast.kotlin.KotlinUastLanguagePlugin.convertElementWithParent(KotlinUastLanguagePlugin.kt:67)
        at org.jetbrains.uast.UastFacade.convertElementWithParent(UastContext.kt:68)
        at org.jetbrains.uast.UastContextKt.toUElement(UastContext.kt:111)
        at com.intellij.codeInspection.apiUsage.ApiUsageUastVisitor.visitSimpleNameReferenceExpression(ApiUsageUastVisitor.kt:80)
        at org.jetbrains.uast.kotlin.KotlinUSimpleReferenceExpression.accept(KotlinUSimpleReferenceExpression.kt:47)
        at com.intellij.uast.UastVisitorAdapter.visitElement(UastVisitorAdapter.java:48)
        at org.jetbrains.kotlin.psi.KtElementImpl.accept(KtElementImpl.java:54)
        at com.intellij.codeInspection.InspectionEngine.acceptElements(InspectionEngine.java:66)
        at com.intellij.codeInspection.InspectionEngine.createVisitorAndAcceptElements(InspectionEngine.java:57)
        at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.runToolOnElements(LocalInspectionsPass.java:311)
        at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.lambda$visitPriorityElementsAndInit$4(LocalInspectionsPass.java:270)
        at com.intellij.util.AstLoadingFilter.forceAllowTreeLoading(AstLoadingFilter.java:156)
        at com.intellij.util.AstLoadingFilter.forceAllowTreeLoading(AstLoadingFilter.java:148)
        at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.lambda$visitPriorityElementsAndInit$5(LocalInspectionsPass.java:268)
        at com.intellij.util.AstLoadingFilter.disallowTreeLoading(AstLoadingFilter.java:127)
        at com.intellij.util.AstLoadingFilter.disallowTreeLoading(AstLoadingFilter.java:116)
        at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.lambda$visitPriorityElementsAndInit$6(LocalInspectionsPass.java:268)
        at com.intellij.concurrency.ApplierCompleter.execAndForkSubTasks(ApplierCompleter.java:136)
        at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1146)
        at com.intellij.concurrency.ApplierCompleter.lambda$wrapInReadActionAndIndicator$1(ApplierCompleter.java:92)
        at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:658)
        at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:610)
        at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:65)
        at com.intellij.concurrency.ApplierCompleter.wrapInReadActionAndIndicator(ApplierCompleter.java:104)
        at com.intellij.concurrency.ApplierCompleter.lambda$compute$0(ApplierCompleter.java:83)
        at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:172)
        at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:189)
        at com.intellij.concurrency.ApplierCompleter.compute(ApplierCompleter.java:83)
        at java.base/java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:746)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
    
    
    

    解决办法

    • 升级或者重装 Android Studio
      这是万能大法。
      然而,我还是想弄明白为啥,所以还没急着升级,先观察一波。
      文尾有下载地址。

    注:下载地址为谷歌中文开发者社区,非营销,非推广!

    • 有人遇到说是 org.jetbrains.kotlin 的问题
      这个是在 Stack Overflow 中看到的。
      提问者也是卡住了,通过升级 org.jetbrains.kotlin 解决问题。
      如文章尾部的参考链接。
      我尝试了一下,会好转。
      我的 kotlin1.6.0 升级到了 1.6.10
      虽然显示 Performing Analysis,但是确实不会反复执行了,只是感觉似乎一直未执行完毕。

    • Flie >> Invalidate Caches/Restart >> Invalidate Caches/Restart
      可能是 plugins 插件出现了问题。
      这里可以考虑清除 Studio 缓存,然后重启。
      这招也接近万能大法了。
      可以解决很多类似问题。

    • 删除缓存 c:/Users/me/AppData/Local/Google/AndroidStudio4.2 (win10)
      这条也是在 Stack Overflow 中看到的。点我看
      不过这篇中更多的推荐是修改Kotlin版本
      不过也可以作为一种尝试记录,都不行的时候,可以试试删这个缓存

    个人尝试

    由于我是kotlin升级和 Invalidate Caches/Restart 同时做的,不太确定哪个具体生效的。
    个人倾向是后者,错误原因可能还是插件的问题。

    其它

    日志错误尚未分析。
    有相关经验的大佬可以在评论区指导一下。

    参考文献

    https://stackoverflow.com/questions/68113077/how-to-resume-a-stuck-code-analysis-in-android-studio
    https://stackoverflow.com/questions/64984549/android-studio-stuck-at-analyzing

    Android Studio Download

    Android Studio 常见问题

    相关文章

      网友评论

          本文标题:AndroidStudio Kotlin Analysis 卡住

          本文链接:https://www.haomeiwen.com/subject/xklzfrtx.html