360

I have an IntelliJ 14.1.2 Project consisting of two modules - one is an Android Gradle based module and the other is a Spring Java-based module with Maven.

gps-trackman.v1 is my root project and I've not configured any outputs or facets for this project. The app is my android gradle module and I've configured Android and Android-Gradle Facet for this project and gps-trackman isn't my Spring Maven Project. I want to be able to build everything all together. Is it possible?

I now get this error message in my IntelliJ Eventlog

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

The project 'gps-trackman.v1' is not a Gradle-based

Is this error just due to a misconfiguration of my project or is it really not possible to have a maven module and a Gradle module in one project?

Do I have to configure any Facets for the root project? Alternatively, do I have to convert my maven to gradle?

Ahmed Nabil
  • 17,392
  • 11
  • 61
  • 88
kamokaze
  • 7,142
  • 5
  • 33
  • 43
  • Are you opposed to converting the maven project to gradle? – RaGe Jan 27 '16 at 18:48
  • Yes, then I've tried to convert the Maven project into a Gradle project, but that resulted in a bunch of other errors, so i would prefer to stay with Maven... – kamokaze Jan 27 '16 at 19:31
  • 1
    Alright, I just wanted to note that it is possible to add a regular java gradle project as a subproject to an android project. – RaGe Jan 27 '16 at 19:37
  • 1
    Are the problems you're having described by JetBrains YouTrack ticket [IDEA-122904](https://youtrack.jetbrains.com/issue/IDEA-122904)? If so, do any of the workarounds listed in there help? –  Jul 01 '16 at 12:30
  • 3
    Possible duplicate of [Android studio Error "Unsupported Modules Detected: Compilation is not supported for following modules"](https://stackoverflow.com/questions/28668252/android-studio-error-unsupported-modules-detected-compilation-is-not-supported) – George Hilliard Oct 17 '17 at 15:59

31 Answers31

571

1- close the project

2- close Android Studio IDE

3- delete the .idea directory

4- delete all .iml files

5- open Android Studio IDE and import the project

Answer from here

Ahmed Nabil
  • 17,392
  • 11
  • 61
  • 88
  • 31
    worked for me with just the deletion of .idea dir, on astudio 3.5 – IulianT Sep 03 '19 at 08:29
  • 3
    Does this work on only specific versions of Android Studio ? – Stealth Rabbi Sep 06 '19 at 11:31
  • 3
    Be careful deleting .idea directory. There is a lot of stuff in that directory that will get lost and not auto-generated when you relaunch A/S. Specifically `codeStyles` and `dictionaries` – tir38 Apr 17 '20 at 17:19
  • 1
    It works for AS 3.6.3 too. I just closed the IDE, deleted the files and reopen. Didn't have to close the project nor import (I believe the IDE does it anyway). – JCarlosR Apr 23 '20 at 15:45
  • @tir38, I think all the files in .idea folder are auto-generated. No need to worry while deleting. Android Studio creates every file by itself. – Neo May 26 '20 at 09:43
  • 11
    more precisely: deleting `modules.xml` from `.idea` directory works. https://stackoverflow.com/a/61813520/1529129 – Rahul Tiwari Jun 10 '20 at 06:29
  • Received this after upgrading `firebase_crashlytics` package in a flutter project (Upgrade from Fabric-based to FB-based: https://firebase.googleblog.com/2020/06/crashlytics-sdk-now-available.html). This solution solved it. – sceee Sep 15 '20 at 16:10
  • It doesn't work on android artic fox, I think it's more related to Gradle but I don't find it... – DavidUps Sep 22 '21 at 08:23
120
  1. Go to File -> Invalidate Caches/Restart.
  2. Close the project.
  3. Go to project folder and delete .idea folder.
  4. Delete YourProjectName.iml in project folder.
  5. Delete app.iml in app folder.
  6. Open Android studio -> open existing project, and then select your project.
  7. The Load Settings error and Unsupported modules detected error will be gone.
Gagan Raghunath
  • 1,673
  • 1
  • 8
  • 5
  • 1
    Thank. It helped me. And the solution is pretty! :) But with: Sync Project with Gradle Files – user_MGU Oct 20 '19 at 09:35
  • What are file will configure in .gitignore, can you please give suggestions for the new project. – MohanRaj S Dec 02 '19 at 13:43
  • 1
    1.a After selecting "Invalidate Caches/Restart" a dialog appears. Make sure to choose the "invalidate" option only and close Android studio manually. If you choose "invalidate + restart" Android studio will restart before you can complete steps 3-5. – Stuart Schechter Feb 07 '20 at 06:44
  • @MohanRajS, all the files which generates automatically must be ignored. For example- every iml file, .idea folder, .gradle folder, build folder, .classpath, .project , .log, .apk, .aab etc. – Neo May 26 '20 at 09:47
  • Just invalidating caches and cleaning the project was enough for me. – frodo2975 Mar 08 '23 at 23:07
76
  1. Close the project
  2. Just delete the modules.xml in .idea folder.
  3. Open the project again.
Nauman Khaliq
  • 909
  • 5
  • 2
46

The ultimate solution to this error:

SOLUTION 1

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

Step 2 Close the project.

Step 3 Go to project folder and delete .idea folder.

Step 4 Delete YourProjectName.iml in project folder.

step 5 You will see a folder below graddle folder, Delete YourProjectName folder (it contains another YourProjectName.iml file).

Step 6 Open Android studio -> open existing project, and then select your project.

**

SOLUTION 2

**

Step 1: Open the Corrupted Project (The one showing error).

Step 2: Open system.gradle file.

step 3: add this line of code include ':app'.

Step 4: click on the sync, to sync the gradle file.

HarshitMadhav
  • 4,769
  • 6
  • 36
  • 45
Obot Ernest
  • 412
  • 8
  • 19
24

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.

21

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

I found this answer here

Community
  • 1
  • 1
Jagruttam Panchal
  • 3,152
  • 2
  • 15
  • 21
  • 9
    I don't use android studio . this is not my case ! – kamokaze Jan 05 '17 at 07:52
  • 1
    Was getting "Unsupported Modules Detected: Compilation is not supported for following modules: mobile. Unfortunately you can't have non-Gradle Java modules and Android-Gradle modules in one project" - this helped me. Thanks! – JC Carrillo Aug 01 '18 at 20:28
14

Tried all above. Didn't work.

Here's what worked. Go to the file called modules.xml

Delete all the modules there. Clean and rebuild.

The Fluffy T Rex
  • 430
  • 7
  • 22
  • 3
    It worked for me. I had this error on a *gradle* module that was later removed but error kept being reported no matter what. Removing the module from modules.xml worked while everything else didn't. – 3c71 Mar 06 '20 at 13:53
10

Make sure you have added your module to the settings.gradle file:

include ':app'
include ':your-module'
Egor Neliuba
  • 14,784
  • 7
  • 59
  • 77
8

Press Ctrl-Alt-S > Uncheck "Android Support" plugin

(I wish I could tell you exactly why this works, but I can't. If you want to develop for Android, try using Android Studio, which is also made by Jetbrains.)

  • 2
    `File -> Settings (= STRG+ALT+S) -> Plugins -> uncheck "Android Support"` [JetBrains Help Page](https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000404920/comments/360000086479) – schemacs Jan 28 '19 at 06:33
  • 2
    In my case I had no such a plugin, but had "Markdown plugin" marked as red incompatible, I uninstalled it and solved the problem after AS restart. – djdance Dec 10 '19 at 11:37
  • turning off the Markdown plugin allowed me to run https://invent.kde.org/network/kdeconnect-android . So can anyone explain why a dumb plugin for a text language would croak the entire build for a phone app?? – Phlip Jun 30 '23 at 04:14
7

Had same issue with Android Studio 3.3 Canary 13.

I was able to solve it by following these steps:

  • Go to the module settings and remove your module from the list
  • Edit settings.gradle and remove your module from there also
  • Physically move the module directory out of the project (to your desktop for instance)
  • Then in the module settings again add a module and select as type 'Import Gradle Project' in which you select the module folder you have moved to your desktop (or anywhere else)

When you complete these steps the module will be copied into your project again, AS will start syncing Gradle again and that succeeds without errors :-) Check your GIT status and you will see as soon as you add your module directory to GIT again that nothing has changed to your working directory. So it's purely an issue with AS that gets somehow out-of-sync...

Based my solution on this comment: https://issuetracker.google.com/issues/37008041#comment3

dirkvranckaert
  • 1,364
  • 1
  • 17
  • 30
5

This may be resolved by fixing .idea/modules.xml
Check for https://stackoverflow.com/a/61343944/11910757

AnonyKnow
  • 219
  • 3
  • 6
4

This happened when there are some cache issues. Just remove .gradle,.idea and app/build folder.

Goto -> AndroidStudio -> File -> Invalidate Cache & Restart

This will open the same project again and Gradle will rebuild all files and caches. This will take around 10-12 minutes. This will definitely be going to help you.

Bharat Lalwani
  • 1,277
  • 15
  • 17
3

This solution worked for me Android Studio 3.3.2.

  1. Delete the .iml file from the project directory.
  2. In android studio File->invalidate caches/restart.
  3. Clean and Rebuild project if the auto build throws error.
Ashutosh dwivedi
  • 510
  • 3
  • 16
3

For some reason, you can not delete the .idea folder

The best way is

  • Delete all files inside of .idea
  • Delete .idea
3

Follow these steps :

1-Command+Shift+F

2-Type : modules.xml

3-Open file

4-Remove those you get error for (the module when you get error once building project)

Good luck :)

Mahdi Giveie
  • 630
  • 1
  • 8
  • 25
3

in my case it work by just invalidate and restart

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 18 '22 at 14:10
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/31103396) – Sadra Feb 23 '22 at 03:51
2

For me, my project was very corrupted. I don't know how I got into that state. What I observed was that several .gradle file and proguard file had a whole bundle of xml content. Fortunately, the physical file had the correct content in it, but android studio was displaying it as some xml file that looked like it belonged to some generated res xml data. Things like "Sync to file system" or "sync project to gradle file", "invalidate cache and restart" or "gradlew clean" wouldn't clear up the issue. I even replaced the bogus xml data being displayed in the gradle scripts with the original content, but that didn't help either. I tried some of the advise given above, but they either didn't work or seemed too complex for me to feel that me project would go back into a well formed state.

So I elected to create a new blank project. Using file explorer, I copied all of the modules in the corrupted project into the new project (a plain old copy and paste) I also replaced the "settings.gradle" and the root "build.gradle" files of the new file with the contents from the old file. Once that is done, you have to run "sync Project with gradle files and you're good to good. If by chance your project root has some content that you physically added, you would have to copy that over too.

So that gets you back up and working. I don't know for sure what caused my project to get corrupted, but I think it might have to do with the laptop going into sleep mode. My laptop was not allowing me wake up from sleep and the only way for me to wake up was to power off an power on again. I did have some projects opened a few times when that happened. So that's my best guess as to how the project might have gotten corrupted.

Tom Rutchik
  • 1,183
  • 1
  • 12
  • 15
2

None of above worked for me but tried something random and it worked.

  1. Copy the corrupted project directory.
  2. Paste it at somewhere else.
  3. Import it in Android Studio. (File-> New-> Import project)
  4. And uncorrupted project get restored.

PS: You must have original corrupted project. (Means, copy it without tampering project structure)

2

goto .idea folder open modules.xml file and see for yourself what module is there that you are not using in project currently.

2

You can simply downgrade your gradle dependency to fit your current android studio version.

dependencies {
        classpath 'com.android.tools.build:gradle:3.5.2'
        ....
}

Worked for me.

m02ph3u5
  • 3,022
  • 7
  • 38
  • 51
2

The following solution I found in this forum worked like a charm:

1- close the project

2- close Android Studio IDE

3- delete the .idea directory in the directory where your app resides

4- delete all .iml files in the directory where your app resides

5- open Android Studio IDE and import the project

1

Copy the project files from the original source and paste it somewhere and then import from the Android Studio.

Shalu T D
  • 3,921
  • 2
  • 26
  • 37
1

Been dealing with this issue for a while every time I tried opening a project.

I always receive this error even though I knew I had not made any changes that should of caused this apart from exporting to zip.

To Fix:

  • Make a new project or open project that works
  • Go to file > open > "your project"
  • Make sure your dummy project stays open. The project you were getting errors should be opened in a new window.

This fixed it for me without doing any changes or deleting anything.

Finks
  • 11
  • 1
1

If nothing works try Import app folder not the Git root while opening Android Project and Error will be gone

Hitesh Sahu
  • 41,955
  • 17
  • 205
  • 154
0

Change the directory of the Project and re-open.

0

Writing in 2020 -

If none of these worked, close android studio and then go to

C:\Users\User.AndroidStudio(ANDROID_STUDIO_VERSION)\system and delete the caches folder

Restart your project now, it should work.

0

In my case I deleted all project from local Repos folder. Then Cloned new Project from bitbucked and imported it again, hopefully error gone.

Samir
  • 6,405
  • 5
  • 39
  • 42
0

Writing in 2023: try invalidate caches and restart

enter image description here

0

if you use firebase, this error can also occur when there is a mismatch between firebase Android package name and project package name. Make sure firebase package name is same as namespace (you can find it here: /andriod/app/build.gradle)

  • 2
    It would be beneficial if you showed examples of the mismatch, and the correction, rather than just pointing to the gradle build script. – amycodes Jun 05 '23 at 17:14
-3

the error explain all things, the idea is confused between gradle and maven.

try to create new project with two gradle modules, you can build spring application with gradle as maven.

see this example from spring guides

Mohamd Ali
  • 2,146
  • 4
  • 23
  • 30
-4

Try to copy and paste from the project files

  • You need to provide somewhat more detail than that, such as _which_ project files (POMs? IntelliJ files? something else) to copy from, and which to copy to. – Jelaby May 05 '22 at 16:19
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/31700267) – Dan May 09 '22 at 19:28