git Android Studio 导入项目与 gradle 更改 iml 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18415541/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android Studio import project with gradle changes iml files
提问by mbmc
I have the following entries in my .gitignore:
我的 .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:
在我 git clone 一个新的 repo 之后(我在项目中没有任何 iml 或 .idea),我打开 Android Studio (v0.2.5),成功导入项目并编译没有问题。现在,如果我想编辑一些文件,IntelliJ 几乎到处都显示红色波浪形的东西,因为它找不到外部库。我意识到当重新生成iml文件时,外部库是这样添加的:
<orderEntry type="library" exported="" scope="TEST" name="guice-3.0-no_aop" level="project" />
FYI, the build.gradle part to add external libraries:
仅供参考,用于添加外部库的 build.gradle 部分:
...
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.
所以现在,如果我打开 Project Structure 弹出窗口并将范围从 Test 更改为 Compile,红色波浪消失,一切都恢复正常。
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.
我想知道这是我做错了什么,还是错误?另外,关于处理 iml 文件的方式(版本与否),我找不到任何直接的答案。似乎每个人都有自己的方式。
Thanks!
谢谢!
采纳答案by mbmc
This issue is fixed, as of Android Studio v0.2.7.
从 Android Studio v0.2.7 开始,此问题已得到修复。
回答by Rémi F
The IDEA official documentation is clear about that :
IDEA 官方文档明确指出:
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.
共享项目根目录下 .idea 目录下的所有文件,除了存储用户特定设置的 workspace.xml 和 tasks.xml 文件,还共享所有 .iml 模块文件。
Source : How to manage IntelliJ IDEA projects under Version Control Systems
来源:如何在版本控制系统下管理 IntelliJ IDEA 项目
EDIT : But, sharing iml files seems to be wrong. Best thing is to use a similar gitignorefile and to import the project in AndroidStudio for each developer.
编辑:但是,共享 iml 文件似乎是错误的。最好的办法是使用类似的gitignore文件并为每个开发人员在 AndroidStudio 中导入项目。