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

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?

This question is related to java android gradle intellij-idea intellij-14

The answer is


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.


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


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.


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


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


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.


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


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.


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

  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.

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


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


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


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.

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

The best way is

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

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

include ':app'
include ':your-module'

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


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


Change the directory of the Project and re-open.


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)


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


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.


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


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.


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.


Examples related to java

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How much should a function trust another function How to implement a simple scenario the OO way Two constructors How do I get some variable from another class in Java? this in equals method How to split a string in two and store it in a field How to do perspective fixing? String index out of range: 4 My eclipse won't open, i download the bundle pack it keeps saying error log

Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to gradle

Gradle - Move a folder from ABC to XYZ A failure occurred while executing com.android.build.gradle.internal.tasks Gradle: Could not determine java version from '11.0.2' Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0 Failed to resolve: com.android.support:appcompat-v7:28.0 Failed to resolve: com.google.firebase:firebase-core:16.0.1 com.google.android.gms:play-services-measurement-base is being requested by various other libraries java.lang.NoClassDefFoundError:failed resolution of :Lorg/apache/http/ProtocolVersion Error - Android resource linking failed (AAPT2 27.0.3 Daemon #0)

Examples related to intellij-idea

IntelliJ: Error:java: error: release version 5 not supported Has been compiled by a more recent version of the Java Runtime (class file version 57.0) Error: Java: invalid target release: 11 - IntelliJ IDEA IntelliJ can't recognize JavaFX 11 with OpenJDK 11 Error: JavaFX runtime components are missing, and are required to run this application with JDK 11 ERROR Source option 1.5 is no longer supported. Use 1.6 or later Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6 How to configure "Shorten command line" method for whole project in IntelliJ intellij idea - Error: java: invalid source release 1.9 Failed to resolve: com.google.android.gms:play-services in IntelliJ Idea with gradle

Examples related to intellij-14

java.io.FileNotFoundException: class path resource cannot be opened because it does not exist Error: Unfortunately you can't have non-Gradle Java modules and > Android-Gradle modules in one project