Error: Unfortunately you can't have non-Gradle Java modules and > Android-Gradle modules in one project

178,172

Solution 1

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

Solution 2

  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.

Solution 3

  1. Close the project
  2. Just delete the modules.xml in .idea folder.
  3. Open the project again.

Solution 4

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.

Solution 5

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.

Share:
178,172
kamokaze
Author by

kamokaze

Java &amp; c#

Updated on February 19, 2022

Comments

  • kamokaze
    kamokaze about 2 years

    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?

  • kamokaze
    kamokaze over 7 years
    I don't use android studio . this is not my case !
  • JC Carrillo
    JC Carrillo almost 6 years
    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!
  • schemacs
    schemacs over 5 years
    File -> Settings (= STRG+ALT+S) -> Plugins -> uncheck "Android Support" JetBrains Help Page
  • IulianT
    IulianT over 4 years
    worked for me with just the deletion of .idea dir, on astudio 3.5
  • Stealth Rabbi
    Stealth Rabbi over 4 years
    Does this work on only specific versions of Android Studio ?
  • user_MGU
    user_MGU over 4 years
    Thank. It helped me. And the solution is pretty! :) But with: Sync Project with Gradle Files
  • MohanRaj S
    MohanRaj S over 4 years
    What are file will configure in .gitignore, can you please give suggestions for the new project.
  • djdance
    djdance over 4 years
    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.
  • Stuart Schechter
    Stuart Schechter over 4 years
    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.
  • Redar
    Redar about 4 years
    deleting .idea folder and .iml file helped.
  • 3c71
    3c71 about 4 years
    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.
  • tir38
    tir38 about 4 years
    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
  • JCarlosR
    JCarlosR about 4 years
    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).
  • Neo
    Neo almost 4 years
    @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
    Neo almost 4 years
    @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.
  • Rahul Tiwari
    Rahul Tiwari almost 4 years
    more precisely: deleting modules.xml from .idea directory works. stackoverflow.com/a/61813520/1529129
  • Afilu
    Afilu almost 4 years
    Worked for me with android studio 4.0
  • Suresh Maidaragi
    Suresh Maidaragi almost 4 years
    Please try to add solution instead redirecting to another websites
  • Nimral
    Nimral almost 4 years
    Worked for me too, needed to rebuild the project before it worked.
  • hushed_voice
    hushed_voice over 3 years
    Damn..worked for me.. cmd+shitf+. to see hidden folders(.idea) in mac btw
  • sceee
    sceee over 3 years
    Received this after upgrading firebase_crashlytics package in a flutter project (Upgrade from Fabric-based to FB-based: firebase.googleblog.com/2020/06/…). This solution solved it.
  • DavidUps
    DavidUps over 2 years
    It doesn't work on android artic fox, I think it's more related to Gradle but I don't find it...
  • Admin
    Admin about 2 years
    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.
  • Sadra
    Sadra about 2 years
    This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
  • mohammad reza sarsarabi
    mohammad reza sarsarabi about 2 years
    this was the only solution that worked for me! of course after invalidate caches and restart.