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

做~自己de王妃 提交于 2019-11-28 21:03:09

问题


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?


回答1:


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:




回答2:


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.




回答3:


simple 'delete my_project.iml file and import project once again using File->New->Project From Existing Sources'




回答4:


I had same problem. Solved it by completely deleting project, then clone it back from GIT.




回答5:


I solve in with
Deletion both gen and gen [generated] from Source Folder.




回答6:


I solved the problem by simply renaming the project. Right click on the project, then click refactor.




回答7:


I fixed the issue by deleting .iml files of modules causing the issue.



来源:https://stackoverflow.com/questions/23734774/when-adding-jar-module-android-must-not-contain-source-root

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!