运行按钮变灰:Android Studio

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22629152/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 06:16:04  来源:igfitidea点击:

Run Button Grayed out: Android Studio

androidandroid-studio

提问by kevingoos

Why is the run button always grayed out in android studio after I had some errors. I need to reboot my android studio every time to run it again. I am sure that I am missing something :P

为什么我遇到一些错误后,android studio 中的运行按钮总是变灰。我每次都需要重新启动我的 android studio 才能再次运行它。我确定我错过了一些东西:P

Run Bar

跑吧

Run Button

运行按钮

I also get an error right now :)

我现在也收到错误:)

Already disposed: Project (Disposed): Already disposed: Project (Disposed)
java.lang.AssertionError: Already disposed: Project (Disposed)
    at com.intellij.openapi.components.impl.ComponentManagerImpl.getComponent(ComponentManagerImpl.java:186)
    at com.intellij.psi.PsiDocumentManager.getInstance(PsiDocumentManager.java:41)
    at com.intellij.psi.SingleRootFileViewProvider.getLastCommittedText(SingleRootFileViewProvider.java:521)
    at com.intellij.psi.SingleRootFileViewProvider.access0(SingleRootFileViewProvider.java:63)
    at com.intellij.psi.SingleRootFileViewProvider$DocumentContent.getText(SingleRootFileViewProvider.java:537)
    at com.intellij.psi.SingleRootFileViewProvider.getContents(SingleRootFileViewProvider.java:347)
    at com.intellij.psi.impl.source.PsiFileImpl.loadTreeElement(PsiFileImpl.java:199)
    at com.intellij.psi.impl.source.PsiFileImpl.calcTreeElement(PsiFileImpl.java:776)
    at com.intellij.psi.impl.source.PsiFileImpl.getFirstChild(PsiFileImpl.java:787)
    at com.intellij.psi.impl.source.xml.XmlFileImpl.getDocument(XmlFileImpl.java:47)
    at com.intellij.psi.impl.source.xml.XmlFileImpl.getRootTag(XmlFileImpl.java:58)
    at com.android.tools.idea.rendering.LocalResourceRepository.getViewTag(LocalResourceRepository.java:323)
    at org.jetbrains.android.inspections.lint.IntellijViewTypeDetector.getViewTags(IntellijViewTypeDetector.java:42)
    at com.android.tools.lint.checks.ViewTypeDetector.visitMethod(ViewTypeDetector.java:213)
    at com.android.tools.lint.client.api.JavaVisitor$DelegatingJavaVisitor.visitMethodInvocation(JavaVisitor.java:1189)
    at lombok.ast.MethodInvocation.accept(MethodInvocation.java:114)
    at lombok.ast.Cast.accept(Cast.java:94)
    at lombok.ast.BinaryExpression.accept(BinaryExpression.java:131)
    at lombok.ast.ExpressionStatement.accept(ExpressionStatement.java:63)
    at lombok.ast.Block.accept(Block.java:106)
    at lombok.ast.MethodDeclaration.accept(MethodDeclaration.java:240)
    at lombok.ast.NormalTypeBody.accept(NormalTypeBody.java:57)
    at lombok.ast.ClassDeclaration.accept(ClassDeclaration.java:239)
    at lombok.ast.CompilationUnit.accept(CompilationUnit.java:83)
    at com.android.tools.lint.client.api.JavaVisitor.visitFile(JavaVisitor.java:217)
    at com.android.tools.lint.client.api.LintDriver.checkIndividualJavaFiles(LintDriver.java:1652)
    at com.android.tools.lint.client.api.LintDriver.runFileDetectors(LintDriver.java:986)
    at com.android.tools.lint.client.api.LintDriver.checkProject(LintDriver.java:858)
    at com.android.tools.lint.client.api.LintDriver.analyze(LintDriver.java:425)
    at com.android.tools.lint.client.api.LintDriver.analyze(LintDriver.java:369)
    at org.jetbrains.android.inspections.lint.AndroidLintExternalAnnotator.doAnnotate(AndroidLintExternalAnnotator.java:146)
    at org.jetbrains.android.inspections.lint.AndroidLintExternalAnnotator.doAnnotate(AndroidLintExternalAnnotator.java:56)
    at com.intellij.codeInsight.daemon.impl.ExternalToolPass.doAnnotate(ExternalToolPass.java:222)
    at com.intellij.codeInsight.daemon.impl.ExternalToolPass.access0(ExternalToolPass.java:43)
    at com.intellij.codeInsight.daemon.impl.ExternalToolPass.run(ExternalToolPass.java:133)
    at com.intellij.codeInsight.daemon.impl.ExternalToolPass.run(ExternalToolPass.java:170)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
    at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:254)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
    at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
    at com.intellij.util.Alarm$Request.run(Alarm.java:327)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at com.intellij.util.concurrency.QueueProcessor$RunnableConsumer.consume(QueueProcessor.java:298)
    at com.intellij.util.concurrency.QueueProcessor$RunnableConsumer.consume(QueueProcessor.java:295)
    at com.intellij.util.concurrency.QueueProcessor.run(QueueProcessor.java:110)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
    at com.intellij.util.concurrency.QueueProcessor.consume(QueueProcessor.java:107)
    at com.intellij.util.concurrency.QueueProcessor.consume(QueueProcessor.java:104)
    at com.intellij.util.concurrency.QueueProcessor.run(QueueProcessor.java:215)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
    at com.intellij.util.concurrency.QueueProcessor.run(QueueProcessor.java:212)
    at com.intellij.openapi.application.impl.ApplicationImpl.run(ApplicationImpl.java:419)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
    at com.intellij.openapi.application.impl.ApplicationImpl.run(ApplicationImpl.java:149)

采纳答案by Anson VanDoren

If you've made major changes to your project structure, it sometimes takes restarting Android Studio to regain the ability to Run your project. Worked for me.

如果您对项目结构进行了重大更改,有时需要重新启动 Android Studio 才能重新获得运行项目的能力。为我工作。

回答by alexandrius

You should initially configure the application. Click the edit configuration in the combo box left to run button then: enter image description here

您应该最初配置应用程序。单击左侧组合框中的编辑配置以运行按钮,然后: 在此处输入图片说明

Last step do:

最后一步做:

enter image description here

在此处输入图片说明

回答by Shimi Uhlman

After an updated of android studio or major changes to your project structure you need to restart android studio and for the first time press run from the dropdown menu

更新 android studio 或对项目结构进行重大更改后,您需要重新启动 android studio 并第一次从下拉菜单中按运行

回答by Hamzah Malik

Happened to me when my module settings weren't right. Go to module settings by right clicking the project in the left pane then make sure the target is set to android-23 or whatever version you want

当我的模块设置不正确时发生在我身上。通过右键单击左窗格中的项目转到模块设置,然后确保目标设置为 android-23 或您想要的任何版本

回答by kevingoos

After an updated of Android studio this week, it worked :)

本周更新了 Android Studio 后,它起作用了:)

回答by rakesh rajput

If you not able to launch android app without activity then perform below mention steps.

如果您无法在没有活动的情况下启动 android 应用程序,请执行以下提到的步骤。

  1. Open Edit Configuration.

  2. Select your application and checked do not launch activity.

  1. 打开编辑配置。

  2. 选择您的应用程序并选中不启动活动。

回答by Vijay Pal

For me, it was an issue with the app module which was not selected after Android Studio update. Select the app module in the combo box left of the run button.

对我来说,这是 Android Studio 更新后未选择的应用模块的问题。在运行按钮左侧的组合框中选择应用程序模块。

回答by Jay

There are many solutions related to this problem.

有许多与此问题相关的解决方案。

Goto setting->plugins->uncheck the red one's and apply. Then again mark them (check them ) and apply .

转到设置-> 插件-> 取消选中红色的并应用。然后再次标记它们(检查它们)并应用。

Restart your android studio , it will work.

重新启动你的 android studio ,它会工作。

回答by Arka Mukherjee

I fixed this issue by re-importing my Gradle Project. For me, everything was greyed out(Run/Debug/Build), and re-starting Android Studio was not enough to fix this issue.

我通过重新导入 Gradle 项目解决了这个问题。对我来说,一切都是灰色的(运行/调试/构建),重新启动 Android Studio 不足以解决这个问题。

I did:

我做了:

File -> Re-Import Gradle Project

After this, the Gradle Sync operation began, and all the buttons in the Android Studio IDE started functioning normally again.

此后,Gradle Sync 操作开始,Android Studio IDE 中的所有按钮再次开始正常运行。

回答by Basant

Go to "Run > Edit Configuration" then go to "Defaults > Android app" then in "General" tab select "App" in module then "Apply".... This is working for me.

转到“运行 > 编辑配置”,然后转到“默认值 > Android 应用程序”,然后在“常规”选项卡中选择模块中的“应用程序”,然后选择“应用”...。这对我有用。

like this

像这样

and like this

像这样