Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio Gradle Already disposed Module

I have installed Android Studio version 1.0.1. I have imported my projects from eclipse and it works fine. Then I deleted a module and reimported it into my Android Studio project. The gradle build says "BUILD SUCCESSFUL" but it pops up an alert window with the message

Failed to complete Gradle execution. Cause: Already disposed: Module: 'MYMODULENAME'

I can't start my app now. Any idea what I can do?

Edit: I solved the problem with the following instructions:

  1. Switch project view from Android to Project
  2. Remove entry include 'MYMODULENAME' in settings.gradle
  3. The blue box in the module symbol don't show. Then you can delete the module in the context menu
  4. Import the module
like image 766
Zenco Avatar asked Dec 18 '14 08:12

Zenco


4 Answers

Note: this is purely an IDEA/AS issue, gradlew clean | Build > Clean | Build > Rebuild will just waste your time.

Most of the solutions here are blind stabbings in the dark. Here's what I found to be the root cause:

  1. Some of the .iml files may be missing (maybe because we deleted it), check if the module erroring has .iml.
  2. If it is missing, check if .idea/modules.xml has an entry for that module

While syncing I noticed that IDEA/AS tries to put a new duplicate entry into .idea/modules.xml while there's already one. This duplicate entry is probably disposed of twice while the sync tries to reset the modules in memory.

Quick Solution: In order to make it work the easiest is to delete .idea/modules.xml along with the .iml files. Additionally may worth deleting .idea/modules/ folder if it exists. Restart Android Studio (no need to clear cache) and force a Gradle sync from Gradle view or toolbar to recreate the files.

like image 120
TWiStErRob Avatar answered Nov 05 '22 07:11

TWiStErRob


I figured out this problem by:

  1. ./gradlew clean
  2. Restart Android Studio
like image 22
Hsiao-Ting Avatar answered Nov 05 '22 07:11

Hsiao-Ting


Simplest solution. (Try this first).

  1. Quit and Restart Android studio. (Quit not close)

  2. Build > Clean your project if needed.

like image 102
user3144836 Avatar answered Nov 05 '22 08:11

user3144836


works for me: File -> Invalidate Caches / Restart... -> Invalidate and Restart

like image 84
polmabri Avatar answered Nov 05 '22 07:11

polmabri