52

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

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.access$400(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.access$400(ExternalToolPass.java:43)
    at com.intellij.codeInsight.daemon.impl.ExternalToolPass$2.run(ExternalToolPass.java:133)
    at com.intellij.codeInsight.daemon.impl.ExternalToolPass$3.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$2.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$1.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$2$1.run(QueueProcessor.java:110)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
    at com.intellij.util.concurrency.QueueProcessor$2.consume(QueueProcessor.java:107)
    at com.intellij.util.concurrency.QueueProcessor$2.consume(QueueProcessor.java:104)
    at com.intellij.util.concurrency.QueueProcessor$3$1.run(QueueProcessor.java:215)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
    at com.intellij.util.concurrency.QueueProcessor$3.run(QueueProcessor.java:212)
    at com.intellij.openapi.application.impl.ApplicationImpl$8.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$1$1.run(ApplicationImpl.java:149)
Sambhav Khandelwal
  • 3,585
  • 2
  • 7
  • 38
kevingoos
  • 3,785
  • 4
  • 36
  • 63

18 Answers18

41

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.

Anson VanDoren
  • 956
  • 1
  • 12
  • 22
39

You should initially configure the application.

  1. Click the edit configuration in the combo box left to run button then: enter image description here
  1. Select the app module

enter image description here

Sambhav Khandelwal
  • 3,585
  • 2
  • 7
  • 38
alexandrius
  • 1,097
  • 1
  • 10
  • 21
20

For me, doing a Gradle sync solved that problem :

  1. File
  2. Sync Project with Gradle Files
Ryan M
  • 18,333
  • 31
  • 67
  • 74
Isma Rekathakusuma
  • 856
  • 12
  • 18
7

After an update 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

Sambhav Khandelwal
  • 3,585
  • 2
  • 7
  • 38
Shimi Uhlman
  • 149
  • 1
  • 6
5

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

Hamzah Malik
  • 2,540
  • 3
  • 28
  • 46
4

After an update of Android studio the week of writing, the issue got resolved

Sambhav Khandelwal
  • 3,585
  • 2
  • 7
  • 38
kevingoos
  • 3,785
  • 4
  • 36
  • 63
4

In my case, this happened after upgrading the MacOS to Catalina and creating a new user. I had to first reinstall Flutter, get the path and add the path permanently to the environmental variables.

Then I had to go Preferences -> Languages and Frameworks -> Flutter -> add the Flutter SDK (where you installed the latest Flutter) to the Flutter SDK path.

palme
  • 2,499
  • 2
  • 21
  • 38
Dyary
  • 753
  • 7
  • 14
3

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

  1. Open Edit Configuration.

  2. Select your application and check the do not launch activity.

Sambhav Khandelwal
  • 3,585
  • 2
  • 7
  • 38
rakesh rajput
  • 606
  • 4
  • 5
3

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.

I did: File -> Re-Import Gradle Project.

After a while, all the buttons in the Android Studio IDE started functioning normally again.

Sambhav Khandelwal
  • 3,585
  • 2
  • 7
  • 38
Arka Mukherjee
  • 2,083
  • 1
  • 13
  • 27
  • 1
    I didn't have this option, the most similar was "File > Invalidate aches / Restart" and it worked for me – Nisba Sep 22 '21 at 12:15
2

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 to the left of the run button.

Sambhav Khandelwal
  • 3,585
  • 2
  • 7
  • 38
Vijay Pal
  • 181
  • 1
  • 2
  • 5
2

There are many solutions related to this problem.

Go to Setting->Plugins->uncheck the red one's and apply. Then again mark them (check them ) and apply .

Restart your android studio , it will work.

Sambhav Khandelwal
  • 3,585
  • 2
  • 7
  • 38
Jay
  • 674
  • 11
  • 13
2

Just sync the Gradle.

Done. This worked for me

Sambhav Khandelwal
  • 3,585
  • 2
  • 7
  • 38
GeneCode
  • 7,545
  • 8
  • 50
  • 85
1

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.

like this

and like this

Sambhav Khandelwal
  • 3,585
  • 2
  • 7
  • 38
Basant
  • 741
  • 7
  • 16
  • I am not getting app option under module, it just shows – gegobyte Dec 05 '18 at 08:15
  • @Chinmay Sarupria, if "app" not appear in drop down then follow these steps "File>Invalidate Caches / Restart...>Invalidate and Restart" and try again above,i hope it will help you – Basant Dec 06 '18 at 09:29
  • Yeah I did something similar, I closed project and reopened it, Gradle synced the project and everything started working. – gegobyte Dec 06 '18 at 10:06
0

Sometimes it happens without any reason. If there is no problem with Run configuration, restarting Android Studio usually helps.

Sambhav Khandelwal
  • 3,585
  • 2
  • 7
  • 38
0

I closed the project, and in the screen listing my recent projects, I removed the project and then went to Open an Existing Android Studio Project -> Open.

This fixed the issue for me.

Sambhav Khandelwal
  • 3,585
  • 2
  • 7
  • 38
Ian Wambai
  • 203
  • 3
  • 19
0

It is very simple solution for the one like me for whom nothing mentioned above worked. Just follow: BuildClean Project

Sambhav Khandelwal
  • 3,585
  • 2
  • 7
  • 38
0

Build -> Clean Project and then Build -> Rebuild Project worked for me.

Rita
  • 223
  • 2
  • 8
0

Sync your project. This fixed my problem.

Dilman Salih
  • 101
  • 10
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 22 '23 at 03:17