Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(when adding jar) - Module "android" must not contain source root

I'm trying to add gdx-tools.jar to a libGDX project in IntelliJ. The result:

Module "android" must not contain source root ".../android/src". The root already belongs to module "android".

This is what I've tried:

project structure > libraries > new project library > java > select "gdx-tools.jar" >select module "desktop"

project structure > modules > select "desktop" > new > jars or directories > select "gdx-tools.jar" >

Ideas?

like image 267
abc32112 Avatar asked May 19 '14 09:05

abc32112


People also ask

What is source root in IntelliJ?

Sources Root - this is where your actual project code goes - typically in src/main/scala (though you can change that, or add extra source directories in your build). Directories nested below this level should be packages. Intellij needs to know these are sources so it can highlight them, check them for errors, etc.

How do I open the project structure in IntelliJ?

To change settings of a module that hosts the file you are currently editing, just press Alt+F1, 7 or open the View menu, select Select In and click Project Structure. IntelliJ IDEA will open the Project Structure dialog and jump to the required module.


2 Answers

Just by going to the Artifacts Settings, Modules, Sources tab, and you will see 2 folders called "gen" and "gen[generated]", delete "gen" by clicking on the X icon to the right of it.

look: enter image description here

like image 64
lucasddaniel Avatar answered Oct 04 '22 04:10

lucasddaniel


I had run into a similar issue as well:

Module "(my_project)" must not contain source root "(my project)/src". The root already belongs to module "(my_project)".

As I couldn't do anything on IDEA's configuration UI, I opened up the IDEA project file (my_project.iml) in vi, hoping to find out what's wrong:

<sourceFolder url="file://$MODULE_DIR$/my_project/src" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/my_project/src" isTestSource="false" /> <!-- Duplicate entry found in project file --> 

So eventually I solved my case by removing the duplicate entry manually.

As the IDEA project files were generated automatically from Gradle files, I have no idea what caused the duplicate entries to be created, but for those facing similar issues, a quick glance at the .iml file may help.

like image 24
Rabby250 Avatar answered Oct 04 '22 06:10

Rabby250