ChatGPT解决这个技术问题 Extra ChatGPT

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

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.

Shared an answer worked for me. Have a try stackoverflow.com/a/57413938/6921788

R
Raphael Pinel

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


do not skip 3 I did and it cost me like 2hours
where are these files located?
.diea and .iml may be hidden. On macOS use command+Shift+period to show hidden files.
Located inside the project folder
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.
D
Danieboy

First of all you should update to Android Studio 1.2 Source: 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.


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.
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.
This still works in 2021 with Android Studio 4.1, thanks
J
Joshua Dyck

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


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.
This works, but one warning -- it will delete your Shelved Changes in Version Control
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.
A
AbhinayMe

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


S
Shahar

Try this if it helps File -> Invalidate Caches / Restart.

If it still doesn't help click on the button in the image. 'Sync Project with Gradle Files'

https://i.stack.imgur.com/uSHmP.png


M
Mohamed Nageh

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.


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.
f
fdermishin

Delete .idea/modules.xml Reload All Gradle Projects

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


M
Michal Zhradnk Nono3551

In my case settings.gradle contained invalid configuration.

I changed:

include ':app' rootProject.name=''

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.


N
Nati Dykstein

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).


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 issue
This was helpful, it contained git conflict with other change
H
Hamza Maqsood

Invalidating caches/Restart didn't worked for me. But simply deleting the caches folder in \Users\user.AndroidStudio(version)\system worked like a charm


B
Boken

You may resolve by below process:

In Android Studio, go to left panel, switch from Android to Project pane Expand .idea folder, you can see modules.xml and open the file. 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" />

Check that match the module name correctly in module element And then, sync the gradle file


d
deva11

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!.


L
Luca C.

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)


N
Name is Nilay

Try the below,

Close android studio Then delete .iml , .idea files Open again the android studio Sync with Gradle.


A
Akhzar Nazir

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.


M
Mushahid Gillani

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.


K
Kirit Khant

Try this steps Individually:-

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...

3) Simply change project location and import project with new location.

Enjoy :-):-)


d
dipakbari4

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

I deleted the .idea folder from project directory. Invalidate caches using Android Studio menu File -> Invalidate Caches / Restart 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.


Just 1 and 2 for Mac users.
A
AgentP

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...


D
David Passmore

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


e
ea_

save .idea folder somewhere else (for backup) remove .idea folder start AndroidStudio select project [there may be an error, ignore that] click File -> Invalidate Caches/ Restart click button: Invalidate Caches/ Restart resolved


P
Panda
Delete .idea folder 
Close project ->
Reopen Project ->
Invalidate Caches / restart

https://i.stack.imgur.com/nbvHz.png


Delete all my carefully fine tuned settings? 😞
G
Ganesh Giri

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


C
CoolMind

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.


L
Levon Petrosyan

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


B
Boonya Kitpitak

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.


R
RajaGuru

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

sure it will work


k
kaushal

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.


u
user4453391

rename project directory fix error for me, android studio 3.4.2


O
Ogulcan Ucarsu

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