Android studio Error "Unsupported Modules Detected: Compilation is not supported for following modules"
Asked Answered
T

33

420

I am using Android studio 1.0.1. I have a java module referred by other modules in my project. I have checked it out from SVN But now every

Unsupported Modules Detected: Compilation is not supported for following modules: . Unfortunately you can't have non-Gradle Java modules and Android-Gradle modules in one project.

After getting this error AS stop compilation of this module so that I am not able to compile/run my project any more.

Trichosis answered 23/2, 2015 at 6:47 Comment(1)
S
237

First of all you should update your Android Studio as stated here: https://code.google.com/p/android/issues/detail?id=77983

Then you should go to File -> Invalidate Caches / Restart -> Invalidate Caches & Restart.

Then try to build the application again.

Spaetzle answered 11/5, 2015 at 16:5 Comment(3)
And...you have to be patient. It make take a while for everything to figure out the changes. I saw the error pop up a 2nd time before the rebuild was complete. But once complete it started working.Arras
Got a file not found on the outdated library which gave me the error mentioned above. So Android Studio has a problem forgetting outdated stuff. Have to remember that.Forceps
Just encountered the issue myself and this remedy worked perfectly. The fix appears to remain relevant to this day (July 2023). I'm running Android Studio Hedgehog | 2023.1.1 Canary 14.Plumlee
C
695
  1. Close the project
  2. Close Android Studio IDE
  3. Delete the .idea directory located inside the project folder
  4. Delete all .iml files
  5. Open Android Studio IDE and import the project
Colima answered 21/3, 2018 at 3:38 Comment(18)
do not skip 3 I did and it cost me like 2hoursArgive
I only had to delete the .iml file of the module that was not being picked.Cytoplasm
@KaushalKishor you are welcome. Ahmed did a great effort in punctuation but it is my answer :)Colima
Thank you, working for me. Does anybody have an idea about what went wrong with ./idea folder and .iml files.Succor
@BharathKumar I think it is android studio versions issue; the iml and idea folders are related to a certain version that then after updating your android studio; it can't read the old filesColima
where are these files located?Enthusiasm
.diea and .iml may be hidden. On macOS use command+Shift+period to show hidden files.Fermentation
Located inside the project folderChickweed
Way more simple (AS 3.6.3): 1. Delete .idea 2. Delete .iml 3. Invalidate caches & RestartSubstitute
If you want to recursively delete .iml files use find . -name "*.iml" -type f -delete on the root folder. Use it without -delete flag to dry run first.Barometry
I've also found some of my java files to be overwritten with some xml.Corridor
After deleting this file as instructed, my app module was not found by android studio. It displays like a normal android module, it doest have that green that as usual, it now have a sky blue box by the side of the module. I think i need help on thisFilth
@MubarakTahir you need to close the project then reopen it. right-click (close the project)Colima
thank you very much man , really thank you like the numbers of the stars in the sky thank you it workedTerrigenous
Steps 1 through 5 (and a half(?)) don't seem to be necessary anymore. Just closing the project and selecting "Import..." worked for me.Goldman
@Goldman Not all people are using the latest version of android studio, so my answer is version-independent. it helped a lot of people as you can see in the comments. So if your issue was solved smoothly that doesn't mean that my answer isn't necessary! Best of luckColima
For Mac users; command + Shift + . to show hidden .idea filesQuip
Amazing that this still works in 2023-09. I accidentally created a second project with the same name. I had a lot of code and didn't see the MyProject2 until starting VCS. I deleted the old project and renamed the Project2, which gave this error after rebuilding everything. Invalidating cache didn't fix my issue. This solution did.Shifrah
S
237

First of all you should update your Android Studio as stated here: https://code.google.com/p/android/issues/detail?id=77983

Then you should go to File -> Invalidate Caches / Restart -> Invalidate Caches & Restart.

Then try to build the application again.

Spaetzle answered 11/5, 2015 at 16:5 Comment(3)
And...you have to be patient. It make take a while for everything to figure out the changes. I saw the error pop up a 2nd time before the rebuild was complete. But once complete it started working.Arras
Got a file not found on the outdated library which gave me the error mentioned above. So Android Studio has a problem forgetting outdated stuff. Have to remember that.Forceps
Just encountered the issue myself and this remedy worked perfectly. The fix appears to remain relevant to this day (July 2023). I'm running Android Studio Hedgehog | 2023.1.1 Canary 14.Plumlee
P
84

Goto .idea/modules.xml & delete the invalid/not existing path <module />. Then File => Invalidate Caches / Restart.

Palacio answered 27/8, 2019 at 2:25 Comment(2)
You can delete whole modules.xml file and invalidate. It works.Serena
Only this worked for me and restart and sync there was no .idea/modules.xml file. Instead there was a .idea/modules/app folder created with two .iml files.Paymaster
D
75

Invalidate Caches and Restart did not work for me. I also updated all my Android Studio files with no success.

The solution I found was importing the android folder by clicking "Import project (Eclipse ADT, Gradle, etc.)" rather than clicking "Open an existing Android Studio Project" or dragging the folder onto the app icon.

Apparently the problem is caused because a module in the project has an *.iml file that does not contain external.system.id="GRADLE".

When you import the project (as opposed to opening it), the iml files are completely re-written, thus removing the error.

I found the info here: https://issuetracker.google.com/issues/37008041

Dada answered 30/8, 2017 at 0:14 Comment(3)
Using Android Studio 3.0.1, I had a new project with local library module dependencies. I directly edited the settings.gradle file to add another library, and that's when I started getting this error. Invalidate Caches & Restart didn't do the trick, but Import did. Could be that the .iml file didn't "catch up" to the Gradle settings file changes.Locular
This works, but one warning -- it will delete your Shelved Changes in Version ControlNummular
This worked best for me. Thanks. Do note that your project directory name should not contain any whitespace at all to avoid any future issues.Ipsambul
O
40

If File -> Invalidate Caches / Restart doesn't help, click on the button in the image:

'Sync Project with Gradle Files'

enter image description here

Outhaul answered 11/9, 2015 at 14:1 Comment(0)
F
20

I know it's an old question. but I faced this problem after updating to Android Studio 3.0. I solved it by deleting app.iml file inside my app module and then Invalidate Caches / Restart.

Frow answered 28/10, 2017 at 10:55 Comment(1)
In my case I had to delete all the .iml files from all the project sub-directories and delete the .idea folder from the project root directory. Then open the Android Studio again. It will recreate those files.Vivle
B
19
  1. Delete .idea/modules.xml
  2. Reload All Gradle Projects

You do not want to remove entire .idea directory, because it contains e.g. dictionaries and shelved changes.

Bassinet answered 1/6, 2020 at 6:59 Comment(1)
I also had to delete .idea/modules directory.Batruk
K
17

In my case settings.gradle contained invalid configuration.

I changed:

include ':app'
rootProject.name='<somthing else>'

To:

include ':app'

Error is gone. So maybe check your settings.gradle for potential errors. If this won't work try to remove cache and other tips.

Kynan answered 12/2, 2020 at 17:59 Comment(0)
P
15

If the above doesn't help you - check your module .iml file and see if it contains any errors. (for the app module it will be app.iml).

Puckett answered 21/8, 2016 at 11:3 Comment(2)
Also check the .iml file inside your .idea folder. Mine didn't have any errors, but an old module was being referenced there, this was causing the issueNeoterize
This was helpful, it contained git conflict with other changeCorset
T
13

You may resolve by below process:

  1. In Android Studio, go to left panel, switch from Android to Project pane

  2. Expand .idea folder, you can see modules.xml and open the file.

  3. In the modules.xml file, you might see like below:

  <component name="...">
    <modules>
      <module fileurl="file://$PROJECT_DIR$/[check...].iml" filepath="$PROJECT_DIR$/[check...].iml" group="myProject" />
      <module fileurl="file://$PROJECT_DIR$/app/[check...]-app.iml" filepath="$PROJECT_DIR$/app/[check...]-app.iml" group="[check...]/app" />

  1. Check that match the module name correctly in module element

  2. And then, sync the gradle file

Tomas answered 21/4, 2020 at 12:48 Comment(0)
S
11

Invalidating caches/Restart didn't work for me, but simply deleting the caches folder in \Users\user.AndroidStudio(version)\system worked.

Sloth answered 16/8, 2019 at 13:47 Comment(0)
D
10

Close the Android Studio and Move ".idea" Folder and paste it outside Project root folder( For Back up if you need).

Open the Android studio. On Opening the project it"ll ask add module (app) to your project. You can ignore the same.

It set set default build variant to be "debug". You can see build variant tab on left corner or hover on "Monitor" Symbol on left bottom

Note: No need to change your .iml file of your project.tom to get build variant option and "Invalidate Cache and Restart" will also not work rather it will clear your history files too!.

Dormie answered 16/11, 2017 at 12:46 Comment(0)
H
9

I solved a similar problem by closing the project, then re-importing the project (not opening, but re-importing as an eclipse or other project)

Hoe answered 30/12, 2017 at 11:47 Comment(0)
G
8

Try the below,

  1. Close android studio
  2. Then delete .iml , .idea files
  3. Open again the android studio
  4. Sync with Gradle.
Gametocyte answered 19/11, 2019 at 10:10 Comment(0)
M
6

In My Case

I have deleted

android -> .idea Folder android -> appname.iml file android -> app -> app.iml file

Open project in Android Studio and no need to File -> Invalidate Caches/Restart

You can do Invalidate Caches / Restart for your case.

Merchantable answered 23/3, 2020 at 11:21 Comment(0)
D
5

The above solution I've tried but didn't work for me.

  1. I deleted the .idea folder from project directory.
  2. Invalidate caches using Android Studio menu File -> Invalidate Caches / Restart
  3. Deleted .gradle folder from user profile directory of Windows 10 operating system. (i.e., C:\Users\YourUserName\.gradle)

Try this solution if the above not working.

Dilapidate answered 29/5, 2020 at 5:42 Comment(1)
Just 1 and 2 for Mac users.Construction
B
4

You should import the the project

https://issuetracker.google.com/issues/37008041

This error shows up when there is a module in your project whose .iml file does not contain: external.system.id="GRADLE" Can you please check your .iml files? Also, instead of opening the project, import it, that will completely rewrite your .iml files and you won't see that error again.

Baldwin answered 27/5, 2018 at 10:1 Comment(0)
O
4

Try:

  1. Go to File->Invalidate Caches / Restart.

  2. Close android studio, Go to C:\Users\(Your UserName)\.AndroidStudio(version)\system and delete caches folder.

If till now nothing worked, then this step will definitely work...

  1. Simply change project location and import project with new location.
Oligopsony answered 20/1, 2020 at 6:13 Comment(0)
T
4
  1. Delete .idea folder
  2. Close project
  3. Reopen Project
  4. Invalidate Caches / restart
Tilth answered 9/9, 2020 at 4:37 Comment(1)
Delete all my carefully fine tuned settings? 😞Forceps
W
3

Step 1 : Delete .iml file

Step 2 : Check if your Project Directory Contain any white spaces if so then Rename your project directory leaving space

ex:

Before : My Project

After rename : MyProject

and open Android Studio...

Wicklund answered 23/12, 2018 at 8:18 Comment(0)
F
2

For windows users, this can also be caused by filesystem corruption.

If all steps above do not correct the error:

  • Close Android Studio
  • Open Command Prompt as Administrator
  • Run a chkdsk /f on the drive your app is stored
  • Delete .idea folder
  • Restart Android Studio
Folkestone answered 9/1, 2019 at 15:8 Comment(0)
W
2
  1. save .idea folder somewhere else (for backup)
  2. remove .idea folder
  3. start AndroidStudio
  4. select project
  5. [there may be an error, ignore that]
  6. click File -> Invalidate Caches/ Restart
  7. click button: Invalidate Caches/ Restart
  8. resolved
Wittgenstein answered 20/12, 2019 at 8:56 Comment(0)
V
2

I had the exact same error and it was so annoying to see the alert every time I stared Android Studio. I tried the solution mentioned above including invalidating cache, restart etc, nothing made it go away.

In my case, we had a module that was deleted from source and the reference also removed from settings.gradle. Turns out, .idea/modules.xml was still referencing that module.

All I needed to do was remove that line from <modules> in .idea/modules.xml and it made it all go away.

Ventilation answered 15/5, 2020 at 0:1 Comment(0)
E
1

You can update new version of Android studio then go to invalidate catches/restart.Click sync button build application.

Edvard answered 18/10, 2016 at 9:7 Comment(0)
W
1

In my case I cloned a git-project where both Java and Kotlin included. Then checked another branch and pressed "Sync Project with Gradle Files". Android Studio 3.0.1.

Welt answered 15/2, 2018 at 14:8 Comment(0)
P
1

I had the same issue on androidStudio 3.2 and clonning the project worked for me

Phasia answered 11/10, 2018 at 12:7 Comment(0)
A
1

In my case it is because the root project name have a space. So instead of naming it as sample project, it should be sample-project or sample_project.

Aramen answered 5/11, 2018 at 13:52 Comment(0)
A
1

click File -> Invalidate Caches/ Restart doesn't help you anymore
Delete .iml , .idea files & folders from file explorer not inside android studio

  1. Open android studio with different/another project

  2. import project newly not from recent

  3. build the project again

Almatadema answered 4/4, 2020 at 7:11 Comment(0)
H
1

I have the same issue. I was tried Invalidate Cache / Restart & also sync project with Gradle Files but still didn't work. But worked by use the following steps:

  1. upgrading gradle distribution version at gradle.wrapper.properties.

    distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
    
  2. And also Android Gradle Plugin at build.gradle project

     classpath 'com.android.tools.build:gradle:4.1.2' //upgrade gradle plugin here
    
  3. Then Invalidate Cache / Restart

  4. That's all solved my problem. Hope you too

Hippo answered 1/2, 2021 at 10:41 Comment(0)
N
0

I have encountered this problem.

I'm using buildSrc in my project.

I think the problem is with buildSrc. To solve the problem;

1- Kotlin and Android Stuido version updated (Kotlin version is 1.3.21, Android Studio version is 3.4)

2- Clean cache and restart android studio

But the problem is not solved.

As a last resort, I deleted the project file and clone it over git and the problem is solved

Nicolette answered 18/8, 2019 at 21:59 Comment(0)
G
0

Delete *.iml file in your project and make invalidate the cache and restart

Gametocyte answered 19/3, 2020 at 7:10 Comment(0)
P
0

All above answer is correct but in my case There is no lib folder available in my app directory and I am trying to call below line in app gradle file

 compile fileTree(include: ['*.jar'], dir: 'libs')

So make sure what ever dependency you declare in gradle file in available for app

Preposition answered 2/8, 2020 at 7:27 Comment(0)
A
-1

Check in build.gradle in app you have good compile link .I have mistake with this line compile 'com.android.support:support-annotations:x.x.x' delete and work.

Arlinda answered 19/2, 2018 at 22:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.