Reputation: 2973
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:
Upvotes: 261
Views: 116968
Reputation: 39
Since the accepted answer didn't work for me here's a solution that did:
After any of the above processes is done an "Invalidate Caches... / Invalidate Caches and Restart" is needed if Android Studio was running otherwise you can just launch it.
Upvotes: -1
Reputation: 21
I have tried the Invalidate cached, remove .idea folder, .gradle folder, all of them does not work, So I remove the full project, then clone the repo again. it solve my problem.
Upvotes: 0
Reputation: 3526
I figured out this problem by:
./gradlew clean
Upvotes: 278
Reputation: 1162
In my case, same as in this question, it happened because I had my project in a symbolic link directory. After reopening the project in the real directory and reconfiguring gradle (File -> Sync with Gradle files
) the problem went away. Shame on you, Android Studio!
Upvotes: 0
Reputation: 301
For Solve this issue take it this simple steps.
.idea
folder in your Android studio under the Folder Project
..idea
--> Find this one. .idea/.modules
.modules
folder and restart Your studio..modules
folder and files.Upvotes: 1
Reputation: 23483
I was having this issue because gradle
and Android Studio
were using a different path for the jvm
. In the Event Log
there was an option for AS and gradle
to use the same path. Selecting this and then doing an invalidate cache & restart
resolved the issue for me.
Upvotes: 0
Reputation: 786
For me this happened when I removed a module and tried to build the project:
Simple solution was to Invalidate the cache & Restart.
Android Studio>File>Invalidate Caches>Invalidate & Restart
Upvotes: 2
Reputation: 71
Although the accepted answer didn't work for me (unfortunately I can't leave a comment), it led me in the right direction.
in .idea/libraries
i found that there were some duplicate xml files (the duplicates were named with a 2 before the _aar.xml
bit).
deleting those, restarting android studio and sync fixed the error
Upvotes: 0
Reputation: 25050
Sometimes gradlew clean
or Invalidate Cache and Restart
does not help, because these methods do not clean Android Studio specific files by themselves.
In this case, close AS and remove .idea
directory and .iml
file in a root project where settings.gradle
file exists. This will make AS rebuild from the fresh ground.
Upvotes: 11
Reputation: 11921
For an alternative solution, check if you added your app to settings.gradle successfully
include ':app'
Upvotes: 4
Reputation: 179
If gradle clean
and/or Build -> Clean Project
didn't help try to re-open the project:
Warning Be aware it's a destructive operation - you're going to loose the project bookmarks, breakpoints and shelves
Upvotes: 1
Reputation: 46460
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:
.iml
files may be missing (maybe because we deleted it),
check if the module erroring has .iml
..idea/modules.xml
has an entry for that moduleWhile 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.
Upvotes: 363
Reputation: 10778
Had a similar issue when working with RN components in my Android project and the only way to get around this issue was to ignore the gradle project.
To do this:
No idea what causes this but I've had this happen to me when using React Native Maps.
Note: If you're still having issues following this. Try to refresh the gradle project which was causing issues.
Upvotes: 1
Reputation: 189
I had the same problem, after delete some gradle files (of aws)
i solved it by mark them "ignore gradle"
I believe it is not the best answer but it solve it for me
Gradle (at the right bar)--> right click on the problematic gradle --> ignore
Upvotes: 0
Reputation: 5075
I also face this problem sometimes. Click on gradle console in bottom bar of android studio, at right side. It will show the exact error in logs. My problem was that I had compile SDK 22 and imported appcomact library was of sdk 23.
Upvotes: 0
Reputation: 3086
For me this happened when i deleted a module and built a new one with the same package name Solution:
Clean & Restart Studio
Upvotes: 6
Reputation: 1163
works for me: File -> Invalidate Caches / Restart... -> Invalidate and Restart
Upvotes: 85
Reputation: 29729
Upvotes: 5
Reputation: 4148
Simplest solution. (Try this first).
Quit and Restart Android studio. (Quit not close)
Build > Clean your project if needed.
Upvotes: 102