如何从 Git 导入 Android Studio 项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21541303/
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
How to import Android Studio Project from Git
提问by Nath5
I have and android studio project that I have checked into git. My git ignore file looks like:
我有一个 android studio 项目,我已经签入了 git。我的 git ignore 文件如下所示:
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
# generated files
bin/
gen/
# Local configuration file (sdk path, etc)
local.properties
# Eclipse project files
.classpath
.project
# Proguard folder generated by Eclipse
proguard/
# Intellij project files
*.iws
.idea/workspace.xml
.idea/tasks.xml
/gradle
When I go to my laptop to pull the project down I am not sure whether I should do open or import inside android studio to correctly being in the project. When I do open I get the following error:
当我去我的笔记本电脑下拉项目时,我不确定是否应该在 android studio 中打开或导入才能正确地进入项目。当我打开时,出现以下错误:
Cannot load module file 'D:\dev\android\projects\projectname\ProjectName.iml':
File D:\dev\android\projects\projectname\ProjectName.iml does not exist
Even though that file does exist.
即使该文件确实存在。
When I do import instead of open android studio asks for the path to gradle home and I am not sure what to put in. I am using android studio 0.4.3.
当我导入而不是打开 android studio 要求提供 gradle home 的路径时,我不确定要放入什么。我使用的是 android studio 0.4.3。
Any help would be really appreciated.
任何帮助将非常感激。
Answer:
回答:
I was able to get the project to build by doing open instead of import. However in the process intellij created an additional iml file at the root of my project which doesn't exist on my desktop. Not sure why it was created and if I need it. Can't for the life of me figure out the proper way to push my project into git and then restore it on another machine without causing lots of new files to be generated and break things.
我能够通过打开而不是导入来构建项目。但是,在此过程中,intellij 在我的项目的根目录中创建了一个额外的 iml 文件,该文件在我的桌面上不存在。不知道为什么创建它以及我是否需要它。我一生都无法找出将我的项目推送到 git 然后在另一台机器上恢复它的正确方法,而不会导致生成大量新文件并破坏某些东西。
回答by danijoo
Use import and delete "/gradle" out of your .gitignore Its ok to ignore .gradle, but /gradle should be included in the git.
使用导入并从 .gitignore 中删除“/gradle” 可以忽略 .gradle,但 /gradle 应该包含在 git 中。
At least this is the way i got it working for me.
至少这是我让它为我工作的方式。
回答by wwang
Try is .gitignore
file.
尝试是.gitignore
文件。
You can't import the project is because there are some IDE generated files in your project.
你不能导入项目是因为你的项目中有一些IDE生成的文件。