简体   繁体   English

如何从Git导入Android Studio项目

[英]How to import Android Studio Project from Git

I have and android studio project that I have checked into git. 我有和android studio项目我已经检查了git。 My git ignore file looks like: 我的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. 当我去我的笔记本电脑拉下项目时,我不确定我是否应该在android studio中打开或导入以正确地进入项目。 When I do open I get the following error: 当我打开时,我收到以下错误:

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工作室请求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. 但是在这个过程中,intellij在我项目的根目录下创建了一个额外的iml文件,这个文件在我的桌面上不存在。 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. 不能为我的生活找出正确的方法将我的项目推入git然后在另一台机器上恢复它,而不会导致生成大量新文件并破坏事物。

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. 至少这是我让它为我工作的方式。

Try is .gitignore file. 尝试是.gitignore文件。

.gitignore 的.gitignore

You can't import the project is because there are some IDE generated files in your project. 您无法导入项目是因为项目中有一些IDE生成的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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