简体   繁体   中英

Android Studio import project with gradle changes iml files

I have the following entries in my .gitignore:

...
*.iml
.idea/
...

After I git clone a fresh repo (I don't have any iml or .idea in the project), I open Android Studio (v0.2.5), import the project successfully and compile without issues. Now, if I want to edit some files, IntelliJ is showing the red wavy thing almost everywhere, because it can't find external libraries. I realized that when the iml files are regenerated, the external libraries are added like this:

<orderEntry type="library" exported="" scope="TEST" name="guice-3.0-no_aop" level="project" />

FYI, the build.gradle part to add external libraries:

...
dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
}
...

So now, if I bring the Project Structure pop-up and change the scope from Test to Compile, the red waves disappear, and everything is back to normal.

I'd like to know if it's something that I do wrong on my side, or if it's a bug? Also, regarding the way to handle iml files (version them or not), I couldn't find any straight answer. Everyone seem to do have their own way.

Thanks!

The IDEA official documentation is clear about that :

Share all the files under .idea directory in the project root except the workspace.xml and tasks.xml files which store user specific settings, also share all the .iml module files.

Source : How to manage IntelliJ IDEA projects under Version Control Systems

EDIT : But, sharing iml files seems to be wrong. Best thing is to use a similar gitignore file and to import the project in AndroidStudio for each developer.

自Android Studio v0.2.7起,此问题已得到修复。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM