Android Studio Gradle Already disposed Module
I figured out this problem by:
./gradlew clean
- Restart Android Studio
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:
- Some of the
.iml
files may be missing (maybe because we deleted it), check if the module erroring has.iml
. - 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.
Simplest solution. (Try this first).
Quit and Restart Android studio. (Quit not close)
Build > Clean your project if needed.
works for me: File -> Invalidate Caches / Restart... -> Invalidate and Restart